Part Number Hot Search : 
MD1802FH PSMN0 05000 LS21G 01M321VT TCC76 607039 MC431R
Product Description
Full Text Search
 

To Download AT32UC3C0512C-ALUT Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  features ? high performance, low power 32-bit avr ? microcontroller ? compact single-cycle risc instruction set including dsp instruction set ? built-in floating-point processing unit (fpu) ? read-modify-write instructions and atomic bit manipulation ? performing 1.49 dmips / mhz ? up to 91 dmips running at 66 mhz from flash (1 wait-state) ? up to 49 dmips running at 33 mhz from flash (0 wait-state) ? memory protection unit ? multi-hierarchy bus system ? high-performance data transfers on separate buses for increased performance ? 16 peripheral dma channels improves speed for peripheral communication ? internal high-speed flash ? 512 kbytes, 256 kbytes, 128 kbytes, 64 kbytes versions ? single cycle access up to 33 mhz ?flashvault ? technology allows pre-programmed secure library support for end user applications ? prefetch buffer optimizing instru ction execution at maximum speed ? 100,000 write cycles, 15-year data retention capability ? flash security locks and us er defined configuration area ? internal high-speed sram, si ngle-cycle access at full speed ? 64 kbytes (512 kb and 256 kb flash), 32 kb ytes (128 kb flash), 16 kbytes (64 kb flash) ? 4 kbytes on the multi-layer bus system (hsb ram) ? external memory interface on at32uc3c0 derivatives ? sdram / sram compatible memory bus (16-bit data and 24-bit address buses) ? interrupt controller ? autovectored low latency interrupt service with programmable priority ? system functions ? power and clock manager ? internal 115khz (rcsys) and 8m hz/1mhz (rc8m) rc oscillators ? one 32 khz and two multipurpose oscillators ? clock failure detection ? two phase-lock-loop (pll) allowing independent cpu frequency from usb or can frequency ? windowed watchdog timer (wdt) ? asynchronous timer (ast) with real-tim e clock capability ? counter or calendar mode supported ? frequency meter (freqm) for accurate measuring of clock frequency ? ethernet mac 10/100 mbps interface ? 802.3 ethernet me dia access controller ? supports media independent interf ace (mii) and reduced mii (rmii) ? universal serial bus (usb) ? device 2.0 and embedded host low speed and full speed ? flexible end-point configuration and management with dedicated dma channels ? on-chip transceivers including pull-ups ? one 2-channel controller area network (can) ? can2a and can2b protocol complian t, with high-level mailbox system ? two independent channels, 16 message objects per channel 32117b?avr?03/11 32-bit avr ? microcontroller at32uc3c0512c at32uc3c0256c at32uc3c0128c at32uc3c064c at32uc3c1512c at32uc3c1256c at32uc3c1128c at32uc3c164c at32uc3c2512c at32uc3c2256c at32uc3c2128c at32uc3c264c preliminary
2 32117b?avr-03/11 at32uc3c ? one 4-channel 20-bit pulse width modulation controller (pwm) ? complementary outputs, wi th dead time insertion ? output override and fault protection ? two quadrature decoders ? one 16-channel 12-bit pi pelined analog-to-digital converter (adc) ? dual sample and hold capability allowing 2 synchronous conversions ? single-ended and differential channels, window function ? two 12-bit digital-to-analog converters (dac), with dual ou tput sample system ? four analog comparators ? six 16-bit timer/co unter (tc) channels ? external clock inputs, pwm, capture and various counting capabilities ? one peripheral event controller ? trigger actions in peripherals de pending on events generated from peripherals or from input pins ? deterministic trigger ? 34 events and 22 event actions ? five universal synchronous/asynchro nous receiver/transmitters (usart) ? independent baudrate generator, support for spi, lin, irda and iso7816 interfaces ? support for hardware handshakin g, rs485 interfaces and modem line ? two master/slave serial peripheral interfaces (spi) with chip select signals ? one inter-ic sound (i2s) controller ? compliant with i2s bus specification ? time division multiplexed mode ? three master and three slave two-wi re interfaces (twi), 400kbit/s i 2 c-compatible ? qtouch ? library support ? capacitive touch buttons, sliders, and wheels ?qtouch ? and qmatrix ? acquisition ? on-chip non-intrusive debug system ? nexus class 2+, runtime control, non-intrusive data and program trace ?awire ? single-pin programming trace and de bug interface muxed with reset pin ? nanotrace ? provides trace capabilities through jtag or awire interface ? 3 package options ? 64-pin qfn/tqfp (45 gpio pins) ? 100-pin tqfp (81 gpio pins) ? 144-pin lqfp (123 gpio pins) ? two operating voltage ranges: ? single 5v power supply ? single 3.3v power supply
3 32117b?avr-03/11 at32uc3c 1. description the at32uc3c is a complete system-on-chip microcontroller based on the avr32uc risc processor running at frequencies up to 66 mhz. avr32uc is a high-performance 32-bit risc microprocessor core, designed for cost-sensitive embedded applications, with particular empha- sis on low power consumption, high code density and high performance. the processor implements a memory protection unit (mpu) and a fast and flexible interrupt con- troller for supporting modern operating systems and real-time operating systems. using the secure access unit (sau) together with the mpu provides the required security and integrity. higher computation capabilities ar e achievable either using a ri ch set of dsp instructions or using the floating-point instructions. the at32uc3c incorporates on-chip flash and sram memories for secure and fast access. for applications requiring additional memory, an external memory interface is provided on at32uc3c0 derivatives. the memory direct memory access controller (mdma) enables transfers of block of data from memories to memories without processor involvement. the peripheral direct memory access (pdca) controller enables data transfers between periph- erals and memories without processor involvement. the pdca drastically reduces processing overhead when transferring continuous and large data streams. the at32uc3c incorporates on-chip flash and sram memories for secure and fast access. the flashvault technology allows secure libraries to be programmed into the device. the secure libraries can be executed while the cpu is in secure state, but not read by non-secure software in the device. the device can thus be shipped to end custumers, who are able to program their own code into the device, accessing the secure libraries, without any risk of compromising the proprietary secure code. the power manager improves design flexibility and security. power monitoring is supported by on-chip power-on reset (por), brown-out detectors (bod18, bod33, bod50). the cpu runs from the on-chip rc oscillators, the plls, or the multipurpose oscillators. the asynchro- nous timer (ast) combined with the 32 khz osci llator keeps track of the time. the ast can operate in counter or calendar mode. the device includes six identical 16-bit timer/counter (tc) channels. each channel can be inde- pendently programmed to perform frequency measurement, event counting, interval measurement, pulse generation, delay timing, and pulse width modulation. the pwm module provides four channels with m any configuration options including polarity, edge alignment and waveform non overlap control. the pwm channels can operate indepen- dently, with duty cycles set independently from each other, or in interlinked mode, with multiple channels updated at the same time. it also includes safety feature with fault inputs and the ability to lock the pwm configuration registers and the pwm pin assignment. the at32uc3c also features many communication interfaces for communication intensive applications. in addition to standard serial interfaces like uart, spi or twi, other interfaces like flexible can, usb and ethernet mac are available. the usart supports different communica- tion modes, like spi mode and lin mode. the inter-ic sound controller (i2sc) provides a 5-bit wide, bidirectional, synchronous, digital audio link with off-chip audio devices. the controlle r is compliant with the i2s bus specification.
4 32117b?avr-03/11 at32uc3c the full-speed usb 2.0 device interface supports several usb classes at the same time thanks to the rich end-point configuration. t he on-the-go (otg) host interface allows device like a usb flash disk or a usb printer to be directly connected to the processor. the media-independent interface (mii) and reduced mii (rmii) 10/100 ethernet mac module provides on-chip solutions for network-connected devices. the peripheral event controller (pevc) allows to redirect events from one peripheral or from input pins to another peripheral. it can then trigger, in a deterministic time, an action inside a peripheral without the need of cpu. for instanc e a pwm waveform can directly trigger an adc capture, hence avoiding delays due to software interrupt processing. the at32uc3c features analog functions like adc, dac, analog comparators. the adc inter- face is built around a 12-bit pipelined adc core and is able to control two independent 8-channel or one 16-channel. the adc block is able to measure two different voltages sampled at the same time. the analog comparators can be pair ed to detect when the sensing voltage is within or outside the defined reference window. atmel offers the qtouch library for embedding capacitive touch buttons, sliders, and wheels functionality into avr microcontrollers. the patented charge-transfer signal acquisition offers robust sensing and included fully debounced reporting of touch keys and includes adjacent key suppression ? (aks ? ) technology for unambiguous detection of key events. the easy-to-use qtouch suite toolchain allows you to explore, develop, and debug your own touch applications. at32uc3c integrates a class 2+ nexus 2.0 on-chip debug (ocd) system, with non-intrusive real-time trace, full-speed read/write memory access in addition to basic runtime control. the nanotrace interface enables trace feature for awire- or jtag-based debuggers. the single-pin awire interface allows all features available th rough the jtag interface to be accessed through the reset pin, allowing th e jtag pins to be used for gpio or peripherals.
5 32117b?avr-03/11 at32uc3c 2. overview 2.1 block diagram figure 2-1. block diagram supplied by vddana supplied by vddana peripheral dma controller hsb-pb bridge b hsb-pb bridge a general purpose ios general purpose ios pa pb pc pd pa pb pc pd usb interface id vbof vbus d- d+ canif 32 khz osc rcsys osc0 / osc1 pll0 / pll1 jtag interface mcko mdo[5..0] mseo[1..0] evti_n evto_n tdi rxline[0] pb pb hsb hsb txline[0] rxline[1] txcan[1] peripheral event controller pad_evt mm m s s m high speed bus matrix avr32uc cpu nexus class 2+ ocd instr interface data interface memory interface 64/32/16 kb sram memory protection unit local bus interface m 4 kb hsb ram s s external bus interface (sdram & static memory controller) cas ras sda10 sdck sdcke sdwe ncs[3..0] nrd nwait nwe0 data[15..0] addr[23..0] nwe1 memory dma hsb-pb bridge c pb hsb s m s m configuration registers bus pbb serial peripheral interface 1 dma miso, mosi npcs[3..0] sck usart0 usart2 usart3 dma rxd txd clk rts, cts twck twd two-wire interface 0/1 dma pulse width modulation controller dma digital to analog converter 0/1 dma dac0a/b analog comparator 0a/0b/1a/1b ac0ap/n ac0bp/n ac1ap/n ac1bp/n dac1a/b i2s interface dma timer/counter 1 a[2..0] b[2..0] clk[2..0] quadrature decoder 0/1 qepa qepb qepi xin32 xout32 xin[1:0] xout[1:0] timer/counter 0 clk[2..0] a[2..0] b[2..0] analog to digital converter 0/1 dma adcin[15..0] adcvrefp/n usart1 dma rxd txd clk rts, cts dsr, dtr, dcd, ri pbc pba serial peripheral interface 0 dma sck miso, mosi npcs[3..0] m r w pwml[3..0] pwmh[3..0] adcref0/1 awire reset_n asynchronous timer watchdog timer frequency meter power manager reset controller sleep controller clock controller system control interface gclk[1..0] bods (1.8v, 3.3v, 5v) rc8m ac0aout/ac0bout ac1aout/ac1bout external interrupt controller extint[8:1] nmi two-wire interface 2 dma twd twck ethernet mac dma s col, crs, rxd[3..0], rx_clk, rx_dv, rx_er, tx_clk mdc, txd[3..0], tx_en, tx_er, speed mdio m 512/ 256/ 128/64 kb flash flash controller bclk iws isdo mclk l o c a l b u s dacref isdi tms tck tdo rc120m ext_faults[1:0] twalm usart4 dma rxd txd clk rts, cts
6 32117b?avr-03/11 at32uc3c 2.2 configuration summary table 2-1. configuration summary feature at32uc3c0512c/ at32uc3c0256c/ at32uc3c0128c/ at32uc3c064c at32uc3c1512c/ at32uc3c1256c/ at32uc3c1128c/ at32uc3c164c at32uc3c2512c/ at32uc3c2256c/ at32uc3c2128c/ at32uc3c264c flash 512/256/128/64 kb 512/256/ 128/64 kb 512/256/128/64 kb sram 64/64/32/16kb 64/ 64/32/16kb 64/64/32/16kb hsb ram 4 kb ebi 1 0 0 gpio 123 81 45 external interrupts 8 8 8 twi 3 3 2 usart 5 5 4 peripheral dma channels 16 16 16 peripheral event system 1 1 1 spi 2 2 1 can channels 2 2 2 usb 1 1 1 ethernet mac 10/100 1 rmii/mii 1 rmii/mii 1 mii only i2s 1 1 1 asynchronous timers 1 1 1 timer/counter channels 6 6 3 pwm channels 4x2 qdec 2 2 1 frequency meter 1 watchdog timer 1 power manager 1 oscillators pll 80-240 mhz (pll0/pll1) crystal oscillator 0.4-20 mhz (osc0) crystal oscillator 32 khz (osc32k) rc oscillator 115 khz (rcsys) rc oscillator 8 mhz (rc8m) rc oscillator 120 mhz (rc120m) 0.4-20 mhz (osc1) - 12-bit adc number of channels 1 16 1 16 1 11 12-bit dac number of channels 1 4 1 4 1 2
7 32117b?avr-03/11 at32uc3c analog comparators 4 4 2 jtag 1 awire 1 max frequency 66 mhz package lqfp144 tqfp 100 tqfp64/qfn64 table 2-1. configuration summary feature at32uc3c0512c/ at32uc3c0256c/ at32uc3c0128c/ at32uc3c064c at32uc3c1512c/ at32uc3c1256c/ at32uc3c1128c/ at32uc3c164c at32uc3c2512c/ at32uc3c2256c/ at32uc3c2128c/ at32uc3c264c
8 32117b?avr-03/11 at32uc3c 3. package and pinout 3.1 package the device pins are multiplexed with peripheral functions as described in table 3-1 on page 11 . figure 3-1. qfn64/tqfp64 pinout note: on qfn packages, the exposed pad is unconnected. pa00 1 pa01 2 pa02 3 pa03 4 vddio1 5 gndio1 6 pa04 7 pa05 8 pa06 9 pa07 10 pa08 11 pa09 12 pa16 13 adcvrefp 14 adcvrefn 15 pa19 16 gndana 17 vddana 18 pa20 19 pa21 20 pa22 21 pa23 22 vbus 23 dm 24 dp 25 gndpll 26 vddin_5 27 vddin_33 28 vddcore 29 gndcore 30 pb30 31 pb31 32 pd01 48 pd00 47 pc22 46 pc21 45 pc20 44 pc19 43 pc18 42 pc17 41 pc16 40 pc15 39 pc05 38 pc04 37 gndio2 36 vddio2 35 pc03 34 pc02 33 pd02 49 pd03 50 vddio3 51 gndio3 52 pd11 53 pd12 54 pd13 55 pd14 56 pd21 57 pd27 58 pd28 59 pd29 60 pd30 61 pb00 62 pb01 63 reset_n 64
9 32117b?avr-03/11 at32uc3c figure 3-2. tqfp100 pinout pa00 1 pa01 2 pa02 3 pa03 4 vddio1 5 gndio1 6 pb04 7 pb05 8 pb06 9 pa04 10 pa05 11 pa06 12 pa07 13 pa08 14 pa09 15 pa10 16 pa11 17 pa12 18 pa13 19 pa14 20 pa15 21 pa16 22 adcvrefp 23 adcvrefn 24 pa19 25 gndana 26 vddana 27 pa20 28 pa21 29 pa22 30 pa23 31 pa24 32 pa25 33 vbus 34 dm 35 dp 36 gndpll 37 vddin_5 38 vddin_33 39 vddcore 40 gndcore 41 pb19 42 pb20 43 pb21 44 pb22 45 pb23 46 pb30 47 pb31 48 pc00 49 pc01 50 pd01 75 pd00 74 pc31 73 pc24 72 pc23 71 pc22 70 pc21 69 pc20 68 pc19 67 pc18 66 pc17 65 pc16 64 pc15 63 pc14 62 pc13 61 pc12 60 pc11 59 pc07 58 pc06 57 pc05 56 pc04 55 gndio2 54 vddio2 53 pc03 52 pc02 51 pd02 76 pd03 77 pd07 78 pd08 79 pd09 80 pd10 81 vddio3 82 gndio3 83 pd11 84 pd12 85 pd13 86 pd14 87 pd21 88 pd22 89 pd23 90 pd24 91 pd27 92 pd28 93 pd29 94 pd30 95 pb00 96 pb01 97 reset_n 98 pb02 99 pb03 100
10 32117b?avr-03/11 at32uc3c figure 3-3. lqfp144 pinout pa00 1 pa01 2 pa02 3 pa03 4 vddio1 5 gndio1 6 pb04 7 pb05 8 pb06 9 pb07 10 pb08 11 pb09 12 pb10 13 pb11 14 pb12 15 pb13 16 pb14 17 pb15 18 pb16 19 pb17 20 pa04 21 pa05 22 pa06 23 pa07 24 pa08 25 pa09 26 pa10 27 pa11 28 pa12 29 pa13 30 pa14 31 pa15 32 pa16 33 adcvrefp 34 adcvrefn 35 pa19 36 gndana 37 vddana 38 pa20 39 pa21 40 pa22 41 pa23 42 pa24 43 pa25 44 pa26 45 pa27 46 pa28 47 pa29 48 vbus 49 dm 50 dp 51 gndpll 52 vddin_5 53 vddin_33 54 vddcore 55 gndcore 56 pb18 57 pb19 58 pb20 59 pb21 60 pb22 61 pb23 62 pb24 63 pb25 64 pb26 65 pb27 66 pb28 67 pb29 68 pb30 69 pb31 70 pc00 71 pc01 72 pd01 108 pd00 107 pc31 106 pc30 105 gndio3 104 vddio3 103 pc29 102 pc28 101 pc27 100 pc26 99 pc25 98 pc24 97 pc23 96 pc22 95 pc21 94 pc20 93 pc19 92 pc18 91 pc17 90 pc16 89 pc15 88 pc14 87 pc13 86 pc12 85 pc11 84 pc10 83 pc09 82 pc08 81 pc07 80 pc06 79 pc05 78 pc04 77 gndio2 76 vddio2 75 pc03 74 pc02 73 pd02 109 pd03 110 pd04 111 pd05 112 pd06 113 pd07 114 pd08 115 pd09 116 pd10 117 vddio3 118 gndio3 119 pd11 120 pd12 121 pd13 122 pd14 123 pd15 124 pd16 125 pd17 126 pd18 127 pd19 128 pd20 129 pd21 130 pd22 131 pd23 132 pd24 133 pd25 134 pd26 135 pd27 136 pd28 137 pd29 138 pd30 139 pb00 140 pb01 141 reset_n 142 pb02 143 pb03 144
11 32117b?avr-03/11 at32uc3c 3.2 peripheral multiplexing on i/o lines 3.2.1 multiplexed signals each gpio line can be assigned to one of the peripheral functions. the following table describes the peripheral signals multiplexed to the gpio lines. table 3-1. gpio controller func tion multiplexing tqfp / qfn 64 tqfp 100 lqfp 144 pin g p i o supply pin type (1) gpio function abcde f 1 1 1 pa00 0 vddio1 x1/x2 canif - txline[1] 222pa011 vddio1 x1/x2 canif - rxline[1] pevc - pad_evt [0] 333pa022 vddio1 x1/x2 scif - gclk[0] pevc - pad_evt [1] 444pa033 vddio1 x1/x2 scif - gclk[1] eic - extint[1] 7 10 21 pa04 4 vddana x1/x2 adcin0 usbc - id acifa0 - acaout 8 11 22 pa05 5 vddana x1/x2 adcin1 usbc - vbof acifa0 - acbout 9 12 23 pa06 6 vddana x1/x2 adcin2 ac1ap1 pevc - pad_evt [2] 10 13 24 pa07 7 vddana x1/x2 adcin3 ac1an1 pevc - pad_evt [3] 11 14 25 pa08 8 vddana x1/x2 adcin4 ac1bp1 eic - extint[2] 12 15 26 pa09 9 vddana x1/x2 adcin5 ac1bn1 16 27 pa10 10 vddana x1/x2 adcin6 eic - extint[4] pevc - pad_evt [13] 17 28 pa11 11 vddana x1/x2 adcin7 adcref1 pevc - pad_evt [14] 18 29 pa12 12 vddana x1/x2 ac1ap0 spi0 - npcs[0] ac1ap0 or dac1a 19 30 pa13 13 vddana x1/x2 ac1an0 spi0 - npcs[1] adcin15 20 31 pa14 14 vddana x1/x2 ac1bp0 spi1 - npcs[0] 21 32 pa15 15 vddana x1/x2 ac1bn0 spi1 - npcs[1] ac1bn0 or dac1b 13 22 33 pa16 16 vddana x1/x2 adcref0 dacref 14 23 34 adc refp 15 24 35 adc refn
12 32117b?avr-03/11 at32uc3c 16 25 36 pa19 19 vddana x1/x2 adcin8 eic - extint[1] 19 28 39 pa20 20 vddana x1/x2 adcin9 ac0ap0 ac0ap0 or dac0a 20 29 40 pa21 21 vddana x1/x2 adcin10 ac0bn0 ac0bn0 or dac0b 21 30 41 pa22 22 vddana x1/x2 adcin11 ac0an0 pevc - pad_evt [4] macb - speed 22 31 42 pa23 23 vddana x1/x2 adcin12 ac0bp0 pevc - pad_evt [5] macb - wol 32 43 pa24 24 vddana x1/x2 adcin13 spi1 - npcs[2] 33 44 pa25 25 vddana x1/x2 adcin14 spi1 - npcs[3] eic - extint[0] 45 pa26 26 vddana x1/x2 ac0ap1 eic - extint[1] 46 pa27 27 vddana x1/x2 ac0an1 eic - extint[2] 47 pa28 28 vddana x1/x2 ac0bp1 eic - extint[3] 48 pa29 29 vddana x1/x2 ac0bn1 eic - extint[0] 62 96 140 pb00 32 vddio1 x1 usart0 - clk canif - rxline[1] eic - extint[8] pevc - pad_evt [10] 63 97 141 pb01 33 vddio1 x1 canif - txline[1] pevc - pad_evt [11] 99 143 pb02 34 vddio1 x1 usbc - id pevc - pad_evt [6] tc1 - a1 100 144 pb03 35 vddio1 x1 usbc - vbof pevc - pad_evt [7] 7 7 pb04 36 vddio1 x1/x2 spi1 - mosi canif - rxline[0] qdec1 - qepi macb - txd[2] 8 8 pb05 37 vddio1 x1/x2 spi1 - miso canif - txline[0] pevc - pad_evt [12] usart3 - clk macb - txd[3] 9 9 pb06 38 vddio1 x2/x4 spi1 - sck qdec1 - qepa usart1 - clk macb - tx_er 10 pb07 39 vddio1 x1/x2 spi1 - npcs[0] eic - extint[2] qdec1 - qepb macb - rx_dv 11 pb08 40 vddio1 x1/x2 spi1 - npcs[1] pevc - pad_evt [1] pwm - pwml[0] macb - rxd[0] 12 pb09 41 vddio1 x1/x2 spi1 - npcs[2] pwm - pwmh[0] macb - rxd[1] 13 pb10 42 vddio1 x1/x2 usart1 - dtr spi0 - mosi pwm - pwml[1] table 3-1. gpio controller func tion multiplexing tqfp / qfn 64 tqfp 100 lqfp 144 pin g p i o supply pin type (1) gpio function abcde f
13 32117b?avr-03/11 at32uc3c 14 pb11 43 vddio1 x1/x2 usart1 - dsr spi0 - miso pwm - pwmh[1] 15 pb12 44 vddio1 x1/x2 usart1 - dcd spi0 - sck pwm - pwml[2] 16 pb13 45 vddio1 x1/x2 usart1 - ri spi0 - npcs[0] pwm - pwmh[2] macb - rx_er 17 pb14 46 vddio1 x1/x2 usart1 - rts spi0 - npcs[1] pwm - pwml[3] macb - mdc 18 pb15 47 vddio1 x1/x2 usart1 - cts usart1 - clk pwm - pwmh[3] macb - mdio 19 pb16 48 vddio1 x1/x2 usart1 - rxd spi0 - npcs[2] pwm - ext_ faults[0] canif - rxline[0] 20 pb17 49 vddio1 x1/x2 usart1 - txd spi0 - npcs[3] pwm - ext_ faults[1] canif - txline[0] 57 pb18 50 vddio2 x1/x2 tc0 - clk2 eic - extint[4] 42 58 pb19 51 vddio2 x1/x2 tc0 - a0 spi1 - mosi iisc - isdo macb - crs 43 59 pb20 52 vddio2 x1/x2 tc0 - b0 spi1 - miso iisc - isdi acifa1 - acaout macb - col 44 60 pb21 53 vddio2 x2/x4 tc0 - clk1 spi1 - sck iisc - imck acifa1 - acbout macb - rxd[2] 45 61 pb22 54 vddio2 x1/x2 tc0 - a1 spi1 - npcs[3] iisc - isck scif - gclk[0] macb - rxd[3] 46 62 pb23 55 vddio2 x1/x2 tc0 - b1 spi1 - npcs[2] iisc - iws scif - gclk[1] macb - rx_clk 63 pb24 56 vddio2 x1/x2 tc0 - clk0 spi1 - npcs[1] 64 pb25 57 vddio2 x1/x2 tc0 - a2 spi1 - npcs[0] pevc - pad_evt [8] 65 pb26 58 vddio2 x2/x4 tc0 - b2 spi1 - sck pevc - pad_evt [9] macb - tx_en 66 pb27 59 vddio2 x1/x2 qdec0 - qepa spi1 - miso pevc - pad_evt [10] tc1 - clk0 macb - txd[0] 67 pb28 60 vddio2 x1/x2 qdec0 - qepb spi1 - mosi pevc - pad_evt [11] tc1 - b0 macb - txd[1] 68 pb29 61 vddio2 x1/x2 qdec0 - qepi spi0 - npcs[0] pevc - pad_evt [12] tc1 - a0 31 47 69 pb30 62 vddio2 x1 32 48 70 pb31 63 vddio2 x1 49 71 pc00 64 vddio2 x1/x2 usbc - id spi0 - npcs[1] usart2 - cts tc1 - b2 canif - txline[1] 50 72 pc01 65 vddio2 x1/x2 usbc - vbof spi0 - npcs[2] usart2 - rts tc1 - a2 canif - rxline[1] table 3-1. gpio controller func tion multiplexing tqfp / qfn 64 tqfp 100 lqfp 144 pin g p i o supply pin type (1) gpio function abcde f
14 32117b?avr-03/11 at32uc3c 33 51 73 pc02 66 vddio2 x1 twims0 - twd spi0 - npcs[3] usart2 - rxd tc1 - clk1 macb - mdc 34 52 74 pc03 67 vddio2 x1 twims0 - twck eic - extint[1] usart2 - txd tc1 - b1 macb - mdio 37 55 77 pc04 68 vddio2 x1 twims1 - twd eic - extint[3] usart2 - txd tc0 - b1 38 56 78 pc05 69 vddio2 x1 twims1 - twck eic - extint[4] usart2 - rxd tc0 - a2 57 79 pc06 70 vddio2 x1 pevc - pad_evt [15] usart2 - clk usart2 - cts tc0 - clk2 twims2 - twd twims0 - twalm 58 80 pc07 71 vddio2 x1 pevc - pad_evt [2] ebi - ncs[3] usart2 - rts tc0 - b2 twims2 - twck twims1 - twalm 81 pc08 72 vddio2 x1/x2 pevc - pad_evt [13] spi1 - npcs[1] ebi - ncs[0] usart4 - txd 82 pc09 73 vddio2 x1/x2 pevc - pad_evt [14] spi1 - npcs[2] ebi - addr[23] usart4 - rxd 83 pc10 74 vddio2 x1/x2 pevc - pad_evt [15] spi1 - npcs[3] ebi - addr[22] 59 84 pc11 75 vddio2 x1/x2 pwm - pwmh[3] canif - rxline[1] ebi - addr[21] tc0 - clk0 60 85 pc12 76 vddio2 x1/x2 pwm - pwml[3] canif - txline[1] ebi - addr[20] usart2 - clk 61 86 pc13 77 vddio2 x1/x2 pwm - pwmh[2] eic - extint[7] usart0 - rts 62 87 pc14 78 vddio2 x1/x2 pwm - pwml[2] usart0 - clk ebi - sdcke usart0 - cts 39 63 88 pc15 79 vddio2 x1/x2 pwm - pwmh[1] spi0 - npcs[0] ebi - sdwe usart0 - rxd canif - rxline[1] 40 64 89 pc16 80 vddio2 x1/x2 pwm - pwml[1] spi0 - npcs[1] ebi - cas usart0 - txd canif - txline[1] 41 65 90 pc17 81 vddio2 x1/x2 pwm - pwmh[0] spi0 - npcs[2] ebi - ras iisc - isdo usart3 - txd 42 66 91 pc18 82 vddio2 x1/x2 pwm - pwml[0] eic - extint[5] ebi - sda10 iisc - isdi usart3 - rxd 43 67 92 pc19 83 vddio3 x1/x2 pwm - pwml[2] scif - gclk[0] ebi - data[0] iisc - imck usart3 - cts 44 68 93 pc20 84 vddio3 x1/x2 pwm - pwmh[2] scif - gclk[1] ebi - data[1] iisc - isck usart3 - rts 45 69 94 pc21 85 vddio3 x1/x2 pwm - ext_ faults[0] canif - rxline[0] ebi - data[2] iisc - iws 46 70 95 pc22 86 vddio3 x1/x2 pwm - ext_ faults[1] canif - txline[0] ebi - data[3] usart3 - clk 71 96 pc23 87 vddio3 x1/x2 qdec1 - qepb canif - rxline[1] ebi - data[4] pevc - pad_evt [3] table 3-1. gpio controller func tion multiplexing tqfp / qfn 64 tqfp 100 lqfp 144 pin g p i o supply pin type (1) gpio function abcde f
15 32117b?avr-03/11 at32uc3c 72 97 pc24 88 vddio3 x1/x2 qdec1 - qepa canif - txline[1] ebi - data[5] pevc - pad_evt [4] 98 pc25 89 vddio3 x1/x2 tc1 - clk2 ebi - data[6] scif - gclk[0] usart4 - txd 99 pc26 90 vddio3 x1/x2 qdec1 - qepi tc1 - b2 ebi - data[7] scif - gclk[1] usart4 - rxd 100 pc27 91 vddio3 x1/x2 tc1 - a2 ebi - data[8] eic - extint[0] usart4 - cts 101 pc28 92 vddio3 x1/x2 spi1 - npcs[3] tc1 - clk1 ebi - data[9] usart4 - rts 102 pc29 93 vddio3 x1/x2 spi0 - npcs[1] tc1 - b1 ebi - data[10] 105 pc30 94 vddio3 x1/x2 spi0 - npcs[2] tc1 - a1 ebi - data[11] 73 106 pc31 95 vddio3 x1/x2 spi0 - npcs[3] tc1 - b0 ebi - data[12] pevc - pad_evt [5] usart4 - clk 47 74 107 pd00 96 vddio3 x1/x2 spi0 - mosi tc1 - clk0 ebi - data[13] qdec0 - qepi usart0 - txd 48 75 108 pd01 97 vddio3 x1/x2 spi0 - miso tc1 - a0 ebi - data[14] tc0 - clk1 usart0 - rxd 49 76 109 pd02 98 vddio3 x2/x4 spi0 - sck tc0 - clk2 ebi - data[15] qdec0 - qepa 50 77 110 pd03 99 vddio3 x1/x2 spi0 - npcs[0] tc0 - b2 ebi - addr[0] qdec0 - qepb 111 pd04 100 vddio3 x1/x2 spi0 - mosi ebi - addr[1] 112 pd05 101 vddio3 x1/x2 spi0 - miso ebi - addr[2] 113 pd06 102 vddio3 x2/x4 spi0 - sck ebi - addr[3] 78 114 pd07 103 vddio3 x1/x2 usart1 - dtr eic - extint[5] ebi - addr[4] qdec0 - qepi usart4 - txd 79 115 pd08 104 vddio3 x1/x2 usart1 - dsr eic - extint[6] ebi - addr[5] tc1 - clk2 usart4 - rxd 80 116 pd09 105 vddio3 x1/x2 usart1 - dcd canif - rxline[0] ebi - addr[6] qdec0 - qepa usart4 - cts 81 117 pd10 106 vddio3 x1/x2 usart1 - ri canif - txline[0] ebi - addr[7] qdec0 - qepb usart4 - rts 53 84 120 pd11 107 vddio3 x1/x2 usart1 - txd usbc - id ebi - addr[8] pevc - pad_evt [6] macb - txd[0] 54 85 121 pd12 108 vddio3 x1/x2 usart1 - rxd usbc - vbof ebi - addr[9] pevc - pad_evt [7] macb - txd[1] 55 86 122 pd13 109 vddio3 x2/x4 usart1 - cts usart1 - clk ebi - sdck pevc - pad_evt [8] macb - rxd[0] 56 87 123 pd14 110 vddio3 x1/x2 usart1 - rts eic - extint[7] ebi - addr[10] pevc - pad_evt [9] macb - rxd[1] table 3-1. gpio controller func tion multiplexing tqfp / qfn 64 tqfp 100 lqfp 144 pin g p i o supply pin type (1) gpio function abcde f
16 32117b?avr-03/11 at32uc3c note: 1. refer to ?electrical characteristics? on page 1249 for a description of the electric al properties of the pin types used. see section 3.3 for a description of the various peripheral signals. 3.2.2 peripheral functions each gpio line can be assigned to one of several peripheral functions. the following table describes how the various peripheral functions are selected. the last listed function has priority in case multiple functions are enabled on the same pin. 124 pd15 111 vddio3 x1/x2 tc0 - a0 usart3 - txd ebi - addr[11] 125 pd16 112 vddio3 x1/x2 tc0 - b0 usart3 - rxd ebi - addr[12] 126 pd17 113 vddio3 x1/x2 tc0 - a1 usart3 - cts ebi - addr[13] usart3 - clk 127 pd18 114 vddio3 x1/x2 tc0 - b1 usart3 - rts ebi - addr[14] 128 pd19 115 vddio3 x1/x2 tc0 - a2 ebi - addr[15] 129 pd20 116 vddio3 x1/x2 tc0 - b2 ebi - addr[16] 57 88 130 pd21 117 vddio3 x1/x2 usart3 - txd eic - extint[0] ebi - addr[17] qdec1 - qepi 89 131 pd22 118 vddio1 x1/x2 usart3 - rxd tc0 - a2 ebi - addr[18] scif - gclk[0] 90 132 pd23 119 vddio1 x1/x2 usart3 - cts usart3 - clk ebi - addr[19] qdec1 - qepa 91 133 pd24 120 vddio1 x1/x2 usart3 - rts eic - extint[8] ebi - nwe1 qdec1 - qepb 134 pd25 121 vddio1 x1/x2 tc0 - clk0 usbc - id ebi - nwe0 usart4 - clk 135 pd26 122 vddio1 x1/x2 tc0 - clk1 usbc - vbof ebi - nrd 58 92 136 pd27 123 vddio1 x1/x2 usart0 - txd canif - rxline[0] ebi - ncs[1] tc0 - a0 macb - rx_er 59 93 137 pd28 124 vddio1 x1/x2 usart0 - rxd canif - txline[0] ebi - ncs[2] tc0 - b0 macb - rx_dv 60 94 138 pd29 125 vddio1 x1/x2 usart0 - cts eic - extint[6] usart0 - clk tc0 - clk0 macb - tx_clk 61 95 139 pd30 126 vddio1 x1/x2 usart0 - rts eic - extint[3] ebi - nwait tc0 - a1 macb - tx_en table 3-1. gpio controller func tion multiplexing tqfp / qfn 64 tqfp 100 lqfp 144 pin g p i o supply pin type (1) gpio function abcde f table 3-2. peripheral functions function description gpio controller function multiplexing gpio and gpio peripheral selection a to f nexus ocd aux port connections ocd trace system
17 32117b?avr-03/11 at32uc3c 3.2.3 oscillator pinout the oscillators are not mapped to the normal gp io functions and their muxings are controlled by registers in the system control interface (scif). please refer to the scif chapter for more information about this. 3.2.4 jtag port connections if the jtag is enabled, the jtag will take control over a number of pins, irrespectively of the i/o controller configuration. 3.2.5 nexus ocd aux port connections if the ocd trace system is enabled, the trace system will take control over a number of pins, irre- spectively of the gpio configuration. two different ocd trace pin mappings are possible, awire dataout awire output in two-pin mode jtag port connections jtag debug port oscillators osc0, osc32 table 3-2. peripheral functions function description table 3-3. oscillator pinout qfn64/ tqfp64 pin tqfp100 pin lqfp144 pin pad oscillator pin 31 47 69 pb30 xin0 99 143 pb02 xin1 62 96 140 pb00 xin32 32 48 70 pb31 xout0 100 144 pb03 xout1 63 97 141 pb01 xout32 table 3-4. jtag pinout qfn64/ tqfp64 pin tqfp100 pin lqfp144 pin pin name jtag pin 222pa01tdi 333pa02tdo 444pa03tms 111pa00tck
18 32117b?avr-03/11 at32uc3c depending on the configuration of the ocd axs register. for details, see the avr32uc techni- cal reference manual . 3.2.6 other functions the functions listed in table 3-6 are not mapped to the normal gpio functions. the awire data pin will only be active after the awire is e nabled. the awire dataout pin will only be active after the awire is enabled and the 2_pin_mode command has been sent. 3.3 signals description the following table give details on the signal name classified by peripherals. table 3-5. nexus ocd aux port connections pin axs=0 axs=1 axs=2 evti_n pa08 pb19 pa10 mdo[5] pc05 pc31 pb06 mdo[4] pc04 pc12 pb15 mdo[3] pa23 pc11 pb14 mdo[2] pa22 pb23 pa27 mdo[1] pa19 pb22 pa26 mdo[0] pa09 pb20 pa19 evto_n pd29 pd29 pd29 mcko pd13 pb21 pb26 mseo[1] pd30 pd08 pb25 mseo[0] pd14 pd07 pb18 table 3-6. other functions qfn64/ tqfp64 pin tqfp100 pin lqfp144 pin pad oscillator pin 64 98 142 reset_n awire data 333pa02awire dataout table 3-7. signal description list signal name function type active level comments power vddio1 vddio2 vddio3 i/o power supply power input 4.5v to 5.5v or 3.0v to 3.6 v vddana analog power supply power input 4.5v to 5.5v or 3.0v to 3.6 v
19 32117b?avr-03/11 at32uc3c vddin_5 1.8v voltage regulator input power input power supply: 4.5v to 5.5v or 3.0v to 3.6 v vddin_33 usb i/o power supply power output/ input capacitor connection for the 3.3v voltage regulator or power supply: 3.0v to 3.6 v vddcore 1.8v voltage regulator output power output capacitor connection for the 1.8v voltage regulator gndio1 gndio2 gndio3 i/o ground ground gndana analog ground ground gndcore ground of the core ground gndpll ground of the plls ground analog comparator interface - acifa0/1 ac0an1/ac0an0 negative inputs for comparator ac0a analog ac0ap1/ac0ap0 positive inputs for comparator ac0a analog ac0bn1/ac0bn0 negative inputs for comparator ac0b analog ac0bp1/ac0bp0 positive inputs for comparator ac0b analog ac1an1/ac1an0 negative inputs for comparator ac1a analog ac1ap1/ac1ap0 positive inputs for comparator ac1a analog ac1bn1/ac1bn0 negative inputs for comparator ac1b analog ac1bp1/ac1bp0 positive inputs for comparator ac1b analog acaout/acbout analog comparator outputs output adc interface - adcifa adcin[15:0] adc input pins analog adcref0 analog positive reference 0 voltage input analog adcref1 analog positive reference 1 voltage input analog adcvrefp analog positive reference connected to external capacitor analog table 3-7. signal description list signal name function type active level comments
20 32117b?avr-03/11 at32uc3c adcvrefn analog negative reference connected to external capacitor analog auxiliary port - aux mcko trace data output clock output mdo[5:0] trace data output output mseo[1:0] trace frame control output evti_n event in output low evto_n event out output low awire - aw data awire data i/o dataout awire data output for 2-pin mode i/o controller area network interface - canif rxline[1:0] can channel rxline i/o txline[1:0] can channel txline i/o dac interface - dacifb0/1 dac0a, dac0b dac0 output pins of s/h a analog dac1a, dac1b dac output pins of s/h b analog dacref analog reference voltage input analog external bus interface - ebi addr[23:0] address bus output cas column signal output low data[15:0] data bus i/o ncs[3:0] chip select output low nrd read signal output low nwait external wait signal input low nwe0 write enable 0 output low nwe1 write enable 1 output low ras row signal output low sda10 sdram address 10 line output table 3-7. signal description list signal name function type active level comments
21 32117b?avr-03/11 at32uc3c sdck sdram clock output sdcke sdram clock enable output sdwe sdram write enable output low external interrup t controller - eic extint[8:1] external interrupt pins input nmi_n = extint[0] non-maskable interrupt pin input low general purpose input/output - gpioa, gpiob, gpioc, gpiod pa[29:19] - pa[16:0] parallel i/o controller gpioa i/o pb[31:0] parallel i/o controller gpiob i/o pc[31:0] parallel i/o controller gpioc i/o pd[30:0] parallel i/o controller gpiod i/o inter-ic sound (i2s) controller - iisc imck i2s master clock output isck i2s serial clock i/o isdi i2s serial data in input isdo i2s serial data out output iws i2s word select i/o jtag tck test clock input tdi test data in input tdo test data out output tms test mode select input ethernet mac - macb col collision detect input crs carrier sense and data valid input mdc management data clock output mdio management data input/output i/o rxd[3:0] receive data input table 3-7. signal description list signal name function type active level comments
22 32117b?avr-03/11 at32uc3c rx_clk receive clock input rx_dv receive data valid input rx_er receive coding error input speed speed output txd[3:0] transmit data output tx_clk transmit clock or reference clock input tx_en transmit enable output tx_er transmit coding error output wol wake-on-lan output peripheral event controller - pevc pad_evt[15:0] event input pins input power manager - pm reset_n reset pin input low pulse width modulator - pwm pwmh[3:0] pwml[3:0] pwm output pins output ext_fault[1:0] pwm fault input pins input quadrature decoder- qdec0/qdec1 qepa qepa quadrature input input qepb qepb quadrature input input qepi index input input system controller interface- scif xin0, xin1, xin32 crystal 0, 1, 32k inputs analog xout0, xout1, xout32 crystal 0, 1, 32k output analog gclk0 - gclk1 generic clock pins output serial peripheral in terface - spi0, spi1 miso master in slave out i/o mosi master out slave in i/o table 3-7. signal description list signal name function type active level comments
23 32117b?avr-03/11 at32uc3c npcs[3:0] spi peripheral chip select i/o low sck clock output timer/counter - tc0, tc1 a0 channel 0 line a i/o a1 channel 1 line a i/o a2 channel 2 line a i/o b0 channel 0 line b i/o b1 channel 1 line b i/o b2 channel 2 line b i/o clk0 channel 0 external clock input input clk1 channel 1 external clock input input clk2 channel 2 external clock input input two-wire interface - twims0, twims1, twims2 twalm smbus smbalert i/o low only on twims0, twims1 twck serial clock i/o twd serial data i/o universal synchronous asynchronous receiver tran smitter - usart0, usart1, usart2, usart3, usart4 clk clock i/o cts clear to send input low dcd data carrier detect input low only usart1 dsr data set ready input low only usart1 dtr data terminal ready output low only usart1 ri ring indicator input low only usart1 rts request to send output low rxd receive data input txd transmit data output universal serial bus device - usb dm usb device port data - analog table 3-7. signal description list signal name function type active level comments
24 32117b?avr-03/11 at32uc3c 3.4 i/o line considerations 3.4.1 jtag pins the jtag is enabled if tck is low while the reset_n pin is re leased. the tck, tms, and tdi pins have pull-up resistors when jtag is enabled. the tck pin always have pull-up enabled during reset. the tdo pin is an output, driven at vddio1, and has no pull-up resistor. the jtag pins can be used as gpio pins and muxed with peripherals when the jtag is disabled. please refer to section 3.2.4 for the jtag port connections. 3.4.2 reset_n pin the reset_n pin integrates a pull- up resistor to vddio1. as t he product integr ates a power-on reset cell, the reset_n pin can be left unconnected in case no reset from the system needs to be applied to the product. the reset_n pin is also used for the awire de bug protocol. when the pin is used for debug- ging, it must not be driven by external circuitry. 3.4.3 twi pins when these pins are used for twi, the pins are open-drain outputs with slew-rate limitation and inputs with inputs with spike-filtering. when used as gpio-pins or used for other peripherals, the pins have the same charac teristics as gpio pins. 3.4.4 gpio pins all i/o lines integrate programmable pull-up and pul l-down resistors. most i/o lines integrate drive strength control, see table 3-1 . programming of this pull-up and pull-down resistor or this drive strength is performed independently for each i/o line through the gpio controllers. after reset, i/o lines default as inputs with pull-up/ pull-down resistors disabled. after reset, out- put drive strength is configured to the lowest value to reduce global emi of the device. when the i/o line is configured as analog func tion (adc i/o, ac inputs, dac i/o), the pull-up and pull-down resistors are automatically disabled. dp usb device port data + analog vbus usb vbus monitor and otg negociation analog input id id pin of the usb bus input vbof usb vbus on/off: bus power control port output table 3-7. signal description list signal name function type active level comments
25 32117b?avr-03/11 at32uc3c 4. processor and architecture rev: 2.1.2.0 this chapter gives an overview of the avr32uc cpu. avr32uc is an implementation of the avr32 architecture. a summary of the programming model, instruction set, and mpu is pre- sented. for further details, see the avr32 architecture manual and the avr32uc technical reference manual . 4.1 features ? 32-bit load/store avr32a risc architecture ? 15 general-purpose 32-bit registers ? 32-bit stack pointer, program counter and link register reside in register file ? fully orthogonal instruction set ? privileged and unprivileged modes enabling efficient and secure operating systems ? innovative instruction set together with variable instruction length ensu ring industry leading code density ? dsp extension with saturating arithmetic, and a wide variety of multiply instructions ? 3-stage pipeline allowing one instruction per clock cy cle for most instructions ? byte, halfword, word, and double word memory access ? multiple interrupt priority levels ? mpu allows for operating s ystems with memory protection ? fpu enables hardware accelerate d floating poin t calculations ? secure state for supporting flashvault tm technology 4.2 avr32 architecture avr32 is a new, high-performance 32-bit risc mi croprocessor architectu re, designed for cost- sensitive embedded applications, with particul ar emphasis on low power consumption and high code density. in addition, the instruction set architecture has been tuned to allow a variety of microarchitectures, enabling the avr32 to be implemented as low-, mid-, or high-performance processors. avr32 extends the avr family into the world of 32- and 64-bit applications. through a quantitative approach, a large set of industry recognized benchmarks has been com- piled and analyzed to achieve the best code density in its class. in addition to lowering the memory requirements, a compact code size also contributes to the core?s low power characteris- tics. the processor supports byte and halfword data types without penalty in code size and performance. memory load and store operations are provided for byte, halfword, word, and double word data with automatic sign- or zero extension of halfw ord and byte data. the c-compiler is closely linked to the architecture and is able to expl oit code optimization features, both for size and speed. in order to reduce code size to a minimum, so me instructions have multiple addressing modes. as an example, instructions with immediates often have a compact format with a smaller imme- diate, and an extended format with a larger immediate. in this way, the compiler is able to use the format giving the smallest code size. another feature of the instruction set is that frequently used instructions, like add, have a com- pact format with two operands as well as an extended format with three operands. the larger format increases performance, allowing an addition and a data move in the same instruction in a
26 32117b?avr-03/11 at32uc3c single cycle. load and store instructions have seve ral different formats in order to reduce code size and speed up execution. the register file is organized as sixteen 32-bi t registers and includes the program counter, the link register, and the stack pointer. in addition, register r12 is designed to hold return values from function calls and is used im plicitly by some instructions. 4.3 the avr32uc cpu the avr32uc cpu targets low- and mediu m-performance applications, and provides an advanced on-chip debug (ocd) system, no caches , and a memory protection unit (mpu). a hardware floating point unit (fpu) is also pr ovided through the coprocessor instruction space. java acceleration hardware is not implemented. avr32uc provides three memory interfaces, one high speed bus master for instruction fetch, one high speed bus master for data access, an d one high speed bus slave interface allowing other bus masters to access data rams internal to the cpu. keeping data rams internal to the cpu allows fast access to the rams, reduces latency, and guarantees deterministic timing. also, power consumption is reduced by not needing a full high speed bus access for memory accesses. a dedicated data ram interface is prov ided for communicating with the internal data rams. a local bus interface is provided for connecting the cpu to device-specific high-speed systems, such as floating-point units and i/o controller port s. this local bus has to be enabled by writing a one to the locen bit in the cpucr system regi ster. the local bus is able to transfer data between the cpu and the local bus slave in a single clock cycle. the local bus has a dedicated memory range allocated to it, and data transfers are performed using regular load and store instructions. details on which devices that are mapped into the local bus space is given in the cpu local bus section in the memories chapter. figure 4-1 on page 27 displays the contents of avr32uc.
27 32117b?avr-03/11 at32uc3c figure 4-1. overview of the avr32uc cpu 4.3.1 pipeline overview avr32uc has three pipeline stages, instruction fetch (if), instruction decode (id), and instruc- tion execute (ex). the ex stage is split into three parallel subsections, one arithmetic/logic (alu) section, one multiply (mul) sect ion, and one load/store (ls) section. instructions are issued and complete in order. certain operations require several clock cycles to complete, and in this case, the instruction resides in the id and ex stages for the required num- ber of clock cycles. since there is only three pipeline stages, no inte rnal data forwarding is required, and no data dependencies can arise in the pipeline. figure 4-2 on page 28 shows an overview of the avr32uc pipeline stages. avr32uc cpu pipeline instruction memory controller mpu high speed bus high speed bus ocd system ocd interface interrupt controller interface high speed bus slave high speed bus high speed bus master power/ reset control reset interface cpu local bus master cpu local bus data memory controller cpu ram high speed bus master
28 32117b?avr-03/11 at32uc3c figure 4-2. the avr32uc pipeline 4.3.2 avr32a microarchitecture compliance avr32uc implements an avr32a microarchitecture. the avr32a microarchitecture is tar- geted at cost-sensitive, lower-end applications like smaller microcontrollers. this microarchitecture does not provide dedicated hard ware registers for shadowing of register file registers in interrupt contexts. additionally, it does not provide hardware registers for the return address registers and return status registers. instead, all this information is stored on the system stack. this saves chip area at the expense of slower interrupt handling. 4.3.2.1 interrupt handling upon interrupt initiation, registers r8-r12 are automatically pushed to the system stack. these registers are pushed regardless of the priority level of the pending interrupt. the return address and status register are also automatically pushed to stack. the interrupt handler can therefore use r8-r12 freely. upon interrupt completion, the old r8-r12 registers and status register are restored, and execution continues at the return address stored popped from stack. the stack is also used to store the status register and return address for exceptions and scall . executing the rete or rets instruction at the completion of an exception or system call will pop this status register and continue execution at the popped return address. 4.3.2.2 java support avr32uc does not provide java hardware acceleration. 4.3.2.3 floating point support a fused multiply-accumulate floa ting point unit (fpu), perfor maing a multiply and accumulate as a single operation with no intermediate rounding, therby increasing precision is provided. the floating point hardware conforms to the requirements of the c standard, which is based on the ieee 754 floating point standard. 4.3.2.4 memory protection the mpu allows the user to check all memory accesses for privilege violations. if an access is attempted to an illegal memory address, the access is aborted and an exception is taken. the mpu in avr32uc is specified in t he avr32uc technical reference manual. if id alu mul regfile write prefetch unit decode unit alu unit multiply unit load-store unit ls regfile read
29 32117b?avr-03/11 at32uc3c 4.3.2.5 unaligned reference handling avr32uc does not support unaligned accesses, except for doubleword accesses. avr32uc is able to perform word-aligned st.d and ld.d . any other unaligned memory access will cause an address exception. doubleword -sized accesses with word-align ed pointers will automatically be performed as two word-sized accesses. the following table shows the instructions with support for unaligned addresses. all other instructions requir e aligned addresses. 4.3.2.6 unimplemented instructions the following instructions are unimplemented in avr32uc, and will cause an unimplemented instruction exception if executed: ? all simd instructions ? all coprocessor instructions if no coprocessors are present ? retj, incjosp, popjc, pushjc ? tlbr, tlbs, tlbw ? cache 4.3.2.7 cpu and architecture revision three major revisions of the avr32uc cpu currently exist. the device described in this datasheet uses cpu revision 3. the architecture revision field in the config0 system register identifies which architecture revision is implemented in a specific device. avr32uc cpu revision 3 is fully backward-compatibl e with revisions 1 and 2, ie. code compiled for revision 1 or 2 is binary-compatible with revision 3 cpus. table 4-1. instructions with una ligned reference support instruction supported alignment ld.d word st.d word
30 32117b?avr-03/11 at32uc3c 4.4 programming model 4.4.1 register file configuration the avr32uc register file is shown below. figure 4-3. the avr32uc register file 4.4.2 status register configuration the status register (sr) is split into two halfwords, one upper and one lower, see figure 4-4 and figure 4-5 . the lower word contains the c, z, n, v, and q condition code flags and the r, t, and l bits, while the upper halfword contains information about the mode and state the proces- sor executes in. refer to the avr32 architecture manual for details. figure 4-4. the status register high halfword application bit 0 supervisor bit 31 pc sr int0pc fintpc int1pc smpc r7 r5 r6 r4 r3 r1 r2 r0 bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 int0 sp_app sp_sys r12 r11 r9 r10 r8 exception nmi int1 int2 int3 lr lr bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 sp_sys lr bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 sp_sys lr bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 sp_sys lr bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 sp_sys lr bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 sp_sys lr bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 sp_sys lr secure bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 sp_sec lr ss_status ss_adrf ss_adrr ss_adr0 ss_adr1 ss_sp_sys ss_sp_app ss_rar ss_rsr bit 31 0 0 0 bit 16 interrupt level 0 mask interrupt level 1 mask interrupt level 3 mask interrupt level 2 mask 1 0 0 0 0 1 1 0 0 0 0 0 0 fe i0m gm m1 - d m0 em i2m dm - m2 lc 1 ss initial value bit name i1m mode bit 0 mode bit 1 - mode bit 2 reserved debug state - i3m reserved exception mask global interrupt mask debug state mask secure state
31 32117b?avr-03/11 at32uc3c figure 4-5. the status register low halfword 4.4.3 processor states 4.4.3.1 normal risc state the avr32 processor supports several diff erent execution contexts as shown in table 4-2 . mode changes can be made under software control, or can be caused by external interrupts or exception processing. a mode can be interrupted by a higher priority mode, but never by one with lower priority. nested exceptions can be supported with a minimal software overhead. when running an operating system on the avr32, user processes will typically execute in the application mode. the programs executed in this mode are restricted from executing certain instructions. furthermore, most system registers together with the upper halfword of the status register cannot be accessed. protected memory areas are also not available. all other operating modes are privileged and are collectively called system modes. they have full access to all priv- ileged and unprivileged re sources. after a reset, the proc essor will be in su pervisor mode. 4.4.3.2 debug state the avr32 can be set in a debug state, which allows implementation of software monitor rou- tines that can read out and alter system information for use during application development. this implies that all system and application regist ers, including the status registers and program counters, are accessible in debug state. th e privileged instructions are also available. all interrupt levels are by default disabled when debug state is entered, but they can individually be switched on by the monitor routine by clearing the respective mask bit in the status register. bit 15 bit 0 reserved carry zero sign 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - - - t - bit name initial value 0 0 l q v n z c - overflow saturation - - - lock reserved scratch table 4-2. overview of execution modes, thei r priorities and privilege levels. priority mode securi ty description 1 non maskable interrupt privileged non maskable high priority interrupt mode 2 exception privileged execute exceptions 3 interrupt 3 privileged general purpose interrupt mode 4 interrupt 2 privileged general purpose interrupt mode 5 interrupt 1 privileged general purpose interrupt mode 6 interrupt 0 privileged general purpose interrupt mode n/a supervisor privileged runs supervisor calls n/a application unprivileged normal program execution mode
32 32117b?avr-03/11 at32uc3c debug state can be entered as described in the avr32uc technical reference manual . debug state is exited by the retd instruction. 4.4.3.3 secure state the avr32 can be set in a secure state, that allows a part of the code to execute in a state with higher security levels. the rest of the code can not access resources reserved for this secure code. secure state is used to implemen t flashvault technology. refer to the avr32uc techni- cal reference manual for details. 4.4.4 system registers the system registers are placed outside of the virtual memory space, and are only accessible using the privileged mfsr and mtsr instructions. the table below lis ts the system registers speci- fied in the avr32 architecture, some of which are unused in avr32uc. the programmer is responsible for maintaining correct sequen cing of any instructions following a mtsr instruction. for detail on the system registers, refer to the avr32uc technical reference manual . table 4-3. system registers reg # address name function 0 0 sr status register 1 4 evba exception vector base address 2 8 acba application call base address 3 12 cpucr cpu control register 4 16 ecr exception cause register 5 20 rsr_sup unused in avr32uc 6 24 rsr_int0 unused in avr32uc 7 28 rsr_int1 unused in avr32uc 8 32 rsr_int2 unused in avr32uc 9 36 rsr_int3 unused in avr32uc 10 40 rsr_ex unused in avr32uc 11 44 rsr_nmi unused in avr32uc 12 48 rsr_dbg return status register for debug mode 13 52 rar_sup unused in avr32uc 14 56 rar_int0 unused in avr32uc 15 60 rar_int1 unused in avr32uc 16 64 rar_int2 unused in avr32uc 17 68 rar_int3 unused in avr32uc 18 72 rar_ex unused in avr32uc 19 76 rar_nmi unused in avr32uc 20 80 rar_dbg return address register for debug mode 21 84 jecr unused in avr32uc 22 88 josp unused in avr32uc 23 92 java_lv0 unused in avr32uc
33 32117b?avr-03/11 at32uc3c 24 96 java_lv1 unused in avr32uc 25 100 java_lv2 unused in avr32uc 26 104 java_lv3 unused in avr32uc 27 108 java_lv4 unused in avr32uc 28 112 java_lv5 unused in avr32uc 29 116 java_lv6 unused in avr32uc 30 120 java_lv7 unused in avr32uc 31 124 jtba unused in avr32uc 32 128 jbcr unused in avr32uc 33-63 132-252 reserved reserved for future use 64 256 config0 configuration register 0 65 260 config1 configuration register 1 66 264 count cycle counter register 67 268 compare compare register 68 272 tlbehi unused in avr32uc 69 276 tlbelo unused in avr32uc 70 280 ptbr unused in avr32uc 71 284 tlbear unused in avr32uc 72 288 mmucr unused in avr32uc 73 292 tlbarlo unused in avr32uc 74 296 tlbarhi unused in avr32uc 75 300 pccnt unused in avr32uc 76 304 pcnt0 unused in avr32uc 77 308 pcnt1 unused in avr32uc 78 312 pccr unused in avr32uc 79 316 bear bus error address register 80 320 mpuar0 mpu address register region 0 81 324 mpuar1 mpu address register region 1 82 328 mpuar2 mpu address register region 2 83 332 mpuar3 mpu address register region 3 84 336 mpuar4 mpu address register region 4 85 340 mpuar5 mpu address register region 5 86 344 mpuar6 mpu address register region 6 87 348 mpuar7 mpu address register region 7 88 352 mpupsr0 mpu privilege select register region 0 89 356 mpupsr1 mpu privilege select register region 1 table 4-3. system registers (continued) reg # address name function
34 32117b?avr-03/11 at32uc3c 4.5 exceptions and interrupts in the avr32 architecture, events are used as a common term for exceptions and interrupts. avr32uc incorporates a powerful event handling scheme. the different event sources, like ille- gal op-code and interrupt requests, have different priority levels, ensuring a well-defined behavior when multiple events are received simultaneously. additionally, pending events of a higher priority class may preempt handling of ongoing events of a lower priority class. when an event occurs, the execution of the instru ction stream is halted, and execution is passed to an event handler at an address specified in table 4-4 on page 38 . most of the handlers are placed sequentially in the code sp ace starting at the ad dress specified by evba, with four bytes between each handler. this gives ample space for a jump instruction to be placed there, jump- ing to the event routine itself. a few critical handlers have larg er spacing between them, allowing the entire event routine to be placed directly at the address specified by the evba-relative offset generated by hardware. all interrupt sources have autovectored interrupt service routine (isr) addresses. this allows the interrupt controller to directly specify the isr address as an address 90 360 mpupsr2 mpu privilege select register region 2 91 364 mpupsr3 mpu privilege select register region 3 92 368 mpupsr4 mpu privilege select register region 4 93 372 mpupsr5 mpu privilege select register region 5 94 376 mpupsr6 mpu privilege select register region 6 95 380 mpupsr7 mpu privilege select register region 7 96 384 mpucra unused in this version of avr32uc 97 388 mpucrb unused in this version of avr32uc 98 392 mpubra unused in this version of avr32uc 99 396 mpubrb unused in this version of avr32uc 100 400 mpuapra mpu access permission register a 101 404 mpuaprb mpu access permission register b 102 408 mpucr mpu control register 103 412 ss_status secure state status register 104 416 ss_adrf secure state address flash register 105 420 ss_adrr secure state address ram register 106 424 ss_adr0 secure state address 0 register 107 428 ss_adr1 secure state address 1 register 108 432 ss_sp_sys secure state stack pointer system register 109 436 ss_sp_app secure state stac k pointer application register 110 440 ss_rar secure state return address register 111 444 ss_rsr secure state return status register 112-191 448-764 reserved reserved for future use 192-255 768-1020 impl implementation defined table 4-3. system registers (continued) reg # address name function
35 32117b?avr-03/11 at32uc3c relative to evba. the autovector offset has 14 address bits, giving an offset of maximum 16384 bytes. the target address of the event handle r is calculated as (evba | event_handler_offset), not (evba + event_handler_offse t), so evba and exception code segments must be set up appropriately. the same mechanisms are used to service all different types of events, including interrupt requests, yielding a uniform event handling scheme. an interrupt controller does the priority handling of the interrupts and provides the autovector off- set to the cpu. 4.5.1 system stack issues event handling in avr32uc uses the system stack pointed to by the system stack pointer, sp_sys, for pushing and popping r8 -r12, lr, status register, and return ad dress. since event code may be timing-critical, sp_sys should point to memory addresses in the iram section, since the timing of accesses to this memory section is both fast and deterministic. the user must also make sure that the system stack is large enough so that any event is able to push the required registers to stack. if the system stack is full, and an event occurs, the system will enter an undefined state. 4.5.2 exceptions and interrupt requests when an event other than scall or debug request is received by the core, the following actions are performed atomically: 1. the pending event will not be acce pted if it is masked. the i3 m, i2m, i1m, i0m, em, and gm bits in the status register are used to mask different events. not all events can be masked. a few critical events (nmi, unreco verable exception, tlb multiple hit, and bus error) can not be masked. when an event is accepted, hardware automatically sets the mask bits corresponding to all sources with equal or lower priority. this inhibits acceptance of other events of the same or lower priority, except for the critical events listed above. software may choose to clear some or all of these bits after saving the necessary state if other priority schemes are desired. it is the event source?s respons- ability to ensure that their events are left pending until accepted by the cpu. 2. when a request is accepted, the status register and program counter of the current context is stored to the system stack. if the event is an int0, int1, int2, or int3, reg- isters r8-r12 and lr are also automatically stored to stack. storing the status register ensures that the core is returned to the previous execution mode when the current event handling is completed. when exceptions occur, both the em and gm bits are set, and the application may manually enable nested exceptions if desired by clear- ing the appropriate bit. each exception handler has a dedicated handler address, and this address uniquely identifies the exception source. 3. the mode bits are set to reflect the priority of the accepted event, and the correct regis- ter file bank is selected. the address of the event handler, as shown in table 4-4 on page 38 , is loaded into the program counter. the execution of the event handler routine then continues from the effective address calculated. the rete instruction signals the end of the event. when encountered, the return status register and return address register are popped from the system stack and restored to the status reg- ister and program counter. if the rete instruction returns from int0, int1, int2, or int3, registers r8-r12 and lr are also popped from the system stack. the restored status register contains information allowing the core to resume operation in the previous execution mode. this concludes the event handling.
36 32117b?avr-03/11 at32uc3c 4.5.3 supervisor calls the avr32 instruction set provides a supervisor mode call instruction. the scall instruction is designed so that privileged routines can be called from any context. this facilitates sharing of code between different execution modes. the scall mechanism is designed so that a minimal execution cycle overhead is experienced when performing supervisor routine calls from time- critical event handlers. the scall instruction behaves differently depending on which mode it is called from. the behav- iour is detailed in the instruction se t reference. in order to allow the scall routine to return to the correct context, a return from supervisor call instruction, rets , is implemented. in the avr32uc cpu, scall and rets uses the system stack to store the return address and the status register. 4.5.4 debug requests the avr32 architecture defines a dedicated debug mode. when a debug request is received by the core, debug mode is entered. entry into debug mode can be masked by the dm bit in the status register. upon entry into debug mode, hardware sets the sr.d bit and jumps to the debug exception handler. by default, debug mode executes in the exception context, but with dedicated return address register and return status register. these dedicated registers remove the need for storing this data to the system stack, t hereby improving debuggability. the mode bits in the status register can freely be manipulated in debug mode, to observe registers in all contexts, while retaining full privileges. debug mode is exited by executing the retd instruction. this return s to the previous context. 4.5.5 entry points for events several different event handler entry points exist. in avr32uc, the reset address is 0x80000000. this places the reset address in the boot flash memory area. tlb miss exceptions and scall have a dedicated space relative to evba where their event han- dler can be placed. this speeds up execution by removing the need for a jump instruction placed at the program address jumped to by the event hardware. all other exceptions have a dedicated event routine entry point located relative to evba. the handler routine address identifies the exception source directly. avr32uc uses the itlb and dtlb protection exc eptions to signal a mp u protection violation. itlb and dtlb miss exceptions are used to signal that an access address did not map to any of the entries in the mpu. tlb multiple hit exception indicates that an access address did map to multiple tlb entries, signalling an error. all interrupt requests have entry points located at an offset relative to evba. this autovector off- set is specified by an interrupt controller. the programmer must make sure that none of the autovector offsets interfere with the placement of other code. the autovector offset has 14 address bits, giving an offset of maximum 16384 bytes. special considerations should be made when loading evba with a po inter. due to security con- siderations, the event handlers should be located in non-writeable flash memory, or optionally in a privileged memory protection region if an mpu is present. if several events occur on the same instruction, they are handled in a prioritized way. the priority ordering is presented in table 4-4 on page 38 . if events occur on several instructions at different locations in the pipeline, the events on the oldest instruction are always handled before any events on any younger instruction, even if the younger instruction has events of higher priority
37 32117b?avr-03/11 at32uc3c than the oldest instruction. an instruction b is younger than an instruction a if it was sent down the pipeline later than a. the addresses and priority of simultaneous events are shown in table 4-4 on page 38 . some of the exceptions are unused in avr32uc since it has no mmu, coprocessor interface, or floating- point unit.
38 32117b?avr-03/11 at32uc3c table 4-4. priority and handler addresses for events priority handler address name event source stored return address 1 0x80000000 reset external input undefined 2 provided by ocd system ocd stop cpu ocd system first non-compl eted instruction 3 evba+0x00 unrecoverable exception int ernal pc of offending instruction 4 evba+0x04 tlb multiple hit mpu pc of offending instruction 5 evba+0x08 bus error data fetch data bu s first non-completed instruction 6 evba+0x0c bus error instruction fetch dat a bus first non-completed instruction 7 evba+0x10 nmi external input first non-completed instruction 8 autovectored interrupt 3 request external input first non-completed instruction 9 autovectored interrupt 2 request external input first non-completed instruction 10 autovectored interrupt 1 request external input first non-completed instruction 11 autovectored interrupt 0 request external input first non-completed instruction 12 evba+0x14 instruction address cp u pc of offending instruction 13 evba+0x50 itlb miss mpu pc of offending instruction 14 evba+0x18 itlb protection mpu pc of offending instruction 15 evba+0x1c breakpoint ocd system firs t non-completed instruction 16 evba+0x20 illegal opcode instructio n pc of offending instruction 17 evba+0x24 unimplemented instruction instr uction pc of offending instruction 18 evba+0x28 privilege violation instruc tion pc of offending instruction 19 evba+0x2c floating-point unused 20 evba+0x30 coprocessor absent instruct ion pc of offending instruction 21 evba+0x100 supervisor call instru ction pc(supervisor call) +2 22 evba+0x34 data address (read) cp u pc of offending instruction 23 evba+0x38 data address (write) cpu pc of offending instruction 24 evba+0x60 dtlb miss (read) mpu pc of offending instruction 25 evba+0x70 dtlb miss (write) mpu pc of offending instruction 26 evba+0x3c dtlb protection (read) mpu pc of offending instruction 27 evba+0x40 dtlb protection (write) m pu pc of offending instruction 28 evba+0x44 dtlb modified unused
39 32117b?avr-03/11 at32uc3c 5. memories 5.1 embedded memories ? internal high-speed flash (see table 5-1 on page 40 ) ? 512 kbytes ? 256 kbytes ? 128 kbytes ? 64 kbytes ? 0 wait state access at up to 33 mhz in worst case conditions ? 1 wait state access at up to 66 mhz in worst case conditions ? pipelined flash architecture, allowing burst re ads from sequential fl ash locations, hiding penalty of 1 wait state access ? pipelined flash architecture typically reduces the cycle penalty of 1 wait state operation to only 15% compared to 0 wait state operation ? 100 000 write cycles, 15-year data retention capability ? sector lock capabilities, bootloader protection, security bit ? 32 fuses, erased during chip erase ? user page for data to be preserved during chip erase ? internal high-speed s ram, single-cycle access at full speed (see table 5-1 on page 40 ) ? 64 kbytes ? 32 kbytes ? 16 kbytes ? supplementary internal high-speed system sram (hsb ram), single-cycle access at full speed ? memory space available on system bus for peripherals data. ? 4 kbytes
40 32117b?avr-03/11 at32uc3c 5.2 physical memory map the system bus is implemented as a bus matrix . all system bus addresses are fixed, and they are never remapped in any way, not even in boot. note that avr32uc cpu uses unsegmented translation, as described in the avr32 architecture manual. the 32-bit physical address space is mapped as follows: table 5-1. at32uc3c physical memory map device start address at32uc3 derivatives c0512c c1512c c2512c c0256c c1256c c2256c c0128c c1128c c2128c c064c c164c c264c embedded sram 0x0000_0000 64 kb 64 kb 64 kb 64 kb 32 kb 32 kb 16 kb 16 kb embedded flash 0x8000_0000 512 kb 512 kb 256 kb 256 kb 128 kb 128 kb 64 kb 64 kb sau 0x9000_0000 1 kb 1 kb 1 kb 1 kb 1 kb 1 kb 1 kb 1 kb hsb sram 0xa000_0000 4 kb 4 kb 4 kb 4 kb 4 kb 4 kb 4 kb 4 kb ebi sram cs0 0xc000_0000 16 mb - 16 mb - 16 mb - 16 mb - ebi sram cs2 0xc800_0000 16 mb - 16 mb - 16 mb - 16 mb - ebi sram cs3 0xcc00_0000 16 mb - 16 mb - 16 mb - 16 mb - ebi sram /sdram cs1 0xd000_0000 128 mb - 128 mb - 128 mb - 128 mb - hsb-pb bridge c 0xfffd_0000 64 kb 64 kb 64 kb 64 kb 64 kb 64 kb 64 kb 64 kb hsb-pb bridge b 0xfffe_0000 64 kb 64 kb 64 kb 64 kb 64 kb 64 kb 64 kb 64 kb hsb-pb bridge a 0xffff_0000 64 kb 64 kb 64 kb 64 kb 64 kb 64 kb 64 kb 64 kb
41 32117b?avr-03/11 at32uc3c 5.3 peripheral address map table 5-2. flash memory parameters part number flash size (flash_pw) number of pages (flash_p) page size (flash_w) at32uc3c0512c at32uc3c1512c at32uc3c2512c 512 kbytes 1024 128 words at32uc3c0256c at32uc3c1256c at32uc3c2256c 256 kbytes 512 128 words at32uc3c0128c at32uc3c1128c at32uc3c2128c 128 kbytes 256 128 words at32uc3c064c at32uc3c164c at32uc3c264c 64 kbytes 128 128 words table 5-3. peripheral address mapping address peripheral name 0xfffd0000 pdca peripheral dma controller - pdca 0xfffd1000 mdma memory dma - mdma 0xfffd1400 usart1 universal synchronous/asynchronous receiver/transmitter - usart1 0xfffd1800 spi0 serial peripheral interface - spi0 0xfffd1c00 canif control area network interface - canif 0xfffd2000 tc0 timer/counter - tc0 0xfffd2400 adcifa adc controller interface with touch screen functionality - adcifa 0xfffd2800 usart4 universal synchronous/asynchronous receiver/transmitter - usart4 0xfffd2c00 twim2 two-wire master interface - twim2 0xfffd3000 twis2 two-wire slave interface - twis2
42 32117b?avr-03/11 at32uc3c 0xfffe0000 hflashc flash controller - hflashc 0xfffe1000 usbc usb 2.0 otg interface - usbc 0xfffe2000 hmatrix hsb matrix - hmatrix 0xfffe2400 sau secure access unit - sau 0xfffe2800 smc static memory controller - smc 0xfffe2c00 sdramc sdram controller - sdramc 0xfffe3000 macb ethernet mac - macb 0xffff0000 intc interrupt controller - intc 0xffff0400 pm power manager - pm 0xffff0800 scif system control interface - scif 0xffff0c00 ast asynchronous timer - ast 0xffff1000 wdt watchdog timer - wdt 0xffff1400 eic external interrupt controller - eic 0xffff1800 freqm frequency meter - freqm 0xffff2000 gpio general purpose input/ output controller - gpio 0xffff2800 usart0 universal synchronous/asynchronous receiver/transmitter - usart0 0xffff2c00 usart2 universal synchronous/asynchronous receiver/transmitter - usart2 0xffff3000 usart3 universal synchronous/asynchronous receiver/transmitter - usart3 0xffff3400 spi1 serial peripheral interface - spi1 table 5-3. peripheral address mapping
43 32117b?avr-03/11 at32uc3c 5.4 cpu local bus mapping some of the registers in the gpio module are mapped onto the cpu local bus, in addition to being mapped on the peripheral bus. these registers can therefore be reached both by accesses on the peripheral bus, and by accesses on the local bus. mapping these registers on the local bus allows cycle-deterministic toggling of gpio pins since the cpu and gpio are the only modules connected to this bus. also, since the local bus runs at cpu speed, one write or read operation can be pe rformed per clock cycle to the local bus- mapped gpio registers. 0xffff3800 twim0 two-wire master interface - twim0 0xffff3c00 twim1 two-wire master interface - twim1 0xffff4000 twis0 two-wire slave interface - twis0 0xffff4400 twis1 two-wire slave interface - twis1 0xffff4800 iisc inter-ic sound (i 2s) controller - iisc 0xffff4c00 pwm pulse width modulation controller - pwm 0xffff5000 qdec0 quadrature decoder - qdec0 0xffff5400 qdec1 quadrature decoder - qdec1 0xffff5800 tc1 timer/counter - tc1 0xffff5c00 pevc peripheral event controller - pevc 0xffff6000 acifa0 analog comparators interface - acifa0 0xffff6400 acifa1 analog comparators interface - acifa1 0xffff6800 dacifb0 dac interface - dacifb0 0xffff6c00 dacifb1 dac interface - dacifb1 0xffff7000 aw awire - aw table 5-3. peripheral address mapping
44 32117b?avr-03/11 at32uc3c the following gpio registers are mapped on the local bus: table 5-4. local bus mapped gpio registers port register mode local bus address access a output driver enable register (oder) write 0x40000040 write-only set 0x40000044 write-only clear 0x40000048 write-only toggle 0x4000004c write-only output value register (ovr) write 0x40000050 write-only set 0x40000054 write-only clear 0x40000058 write-only toggle 0x4000005c write-only pin value register (pvr) - 0x40000060 read-only b output driver enable register (oder) write 0x40000140 write-only set 0x40000144 write-only clear 0x40000148 write-only toggle 0x4000014c write-only output value register (ovr) write 0x40000150 write-only set 0x40000154 write-only clear 0x40000158 write-only toggle 0x4000015c write-only pin value register (pvr) - 0x40000160 read-only c output driver enable register (oder) write 0x40000240 write-only set 0x40000244 write-only clear 0x40000248 write-only toggle 0x4000024c write-only output value register (ovr) write 0x40000250 write-only set 0x40000254 write-only clear 0x40000258 write-only toggle 0x4000025c write-only pin value register (pvr) - 0x40000260 read-only
45 32117b?avr-03/11 at32uc3c d output driver enable register (oder) write 0x40000340 write-only set 0x40000344 write-only clear 0x40000348 write-only toggle 0x4000034c write-only output value register (ovr) write 0x40000350 write-only set 0x40000354 write-only clear 0x40000358 write-only toggle 0x4000035c write-only pin value register (pvr) - 0x40000360 read-only table 5-4. local bus mapped gpio registers port register mode local bus address access
46 32117b?avr-03/11 at32uc3c 6. supply and startup considerations 6.1 supply considerations 6.1.1 power supplies the at32uc3c has several types of power supply pins: ? vddio pins (vddio1, vddio2, vddio3): power i/o lines. two voltage ranges are available: 5v or 3.3v nominal. the vddio pins should be connected together. ? vddana: powers the analog part of the device (analog i/os, adc, acs, dacs). 2 voltage ranges available: 5v or 3.3v nominal. ? vddin_5: input voltage for the 1.8v and 3.3v regu lators. two voltage ranges are available: 5v or 3.3v nominal. ? vddin_33: ? usb i/o power supply ? if the device is 3.3v powered: input voltage, voltage is 3.3v nominal. ? if the device is 5v powered: stabilization for the 3.3v voltage regulator, requires external capacitors ? vddcore: stabilization for the 1.8v voltag e regulator, requires external capacitors. ? gndcore: ground pins for the vo ltage regulators and the core. ? gndana: ground pin for an alog part of the design ? gndpll: ground pin for the plls ? gndio pins (gndio1, gndio2, gndio3): ground pins for the i/o lines. the gndio pins should be connected together. see ?electrical characteristics? on page 1249 for power consumption on the various supply pins. for decoupling recommendations for the different power supplies, please refer to the schematic checklist. 6.1.2 voltage regulators the at32uc3c embeds two voltage regulators: ? one 1.8v internal regulator that converts from vddin_5 to 1.8v. the regulator supplies the output voltage on vddcore. ? one 3.3v internal regulator that converts from vddin_5 to 3.3v. the regulator supplies the usb pads on vddin_33. if the usb is not used, the 3.3v regulator can be disabled through the vreg33ctl field of the vregctrl scif register. 6.1.3 regulators connection the at32uc3c supports two power supply configurations. ? 5v single supply mode ? 3.3v single supply mode 6.1.3.1 5v single supply mode in 5v single supply mode, the 1.8v internal regulator is connected to the 5v source (vddin_5 pin) and its output feeds vddcore. the 3.3v regulator is connected to the 5v sour ce (vddin_5 pin) and its output feeds the usb pads. if the usb is not used, the 3.3v regulator can be disabled through the vreg33ctl field of the vregctrl scif register.
47 32117b?avr-03/11 at32uc3c figure 6-1 on page 47 shows the power schematics to be used for 5v single supply mode. all i/o lines and analog blocks will be powered by the same power (vddin_5 = vddio1 = vddio2 = vddio3 = vddana). figure 6-1. 5v single power supply mode 6.1.3.2 3.3v single supply mode in 3.3v single supply mode, the vddin_5 and vddin_33 pins should be connected together externally. the 1.8v internal regulator is connected to the 3.3v source (vddin_5 pin) and its output feeds vddcore. the 3.3v regulator should be disabled once the circuit is running through the vreg33ctl field of the vregctrl scif register. figure 6-2 on page 48 shows the power schematics to be used for 3.3v single supply mode. all i/o lines and analog blocks will be powered by the same power (vddin_5 = vddin_33 = vddio1 = vddio2 = vddio3 = vddana). vddio1 vddio2 vddio3 cpu peripherals memories scif, bod, rcsys 3.3v reg + - analog: adc, ac, dac, ... vddin_5 vddana gndana vddcore c out2 c out1 gndcore gndpll pll gndio1 gndio2 gndio3 bod50 bod18 bod33 1.8v reg por c in2 c in1 vddin_33 c out2 c out1 4.5- 5.5v
48 32117b?avr-03/11 at32uc3c figure 6-2. 3 single power supply mode 6.1.4 power-up sequence 6.1.4.1 maximum rise rate to avoid risk of latch-up, the rise rate of the power supplies must not exceed the values described in table 40-2 on page 1250 . recommended order for power supplies is also described in this table. 6.1.4.2 minimum rise rate the integrated power-reset circuitry monitori ng the powering supply requires a minimum rise rate for the vddin_5 power supply. see table 40-2 on page 1250 for the minimum rise rate value. if the application can not ensure that the minimum rise rate condition for the vddin power sup- ply is met, the following configuration can be used: ? a logic ?0? value is applied durin g power-up on pin reset_n until: ? vddin_5 rises above 4.5v in 5v single supply mode. ? vddin_33 rises above 3v in 3.3v single supply mode. vddin_33 cpu peripherals memories scif, bod, rcsys 3.3v reg analog: adc, ac, dac, ... vddin_5 vddana gndana vddcore c out2 c out1 gndcore gndpll pll bod50 bod33 1.8v reg bod18 por + - 3.0- 3.6v c in2 c in1 vddio1 vddio2 vddio3 gndio1 gndio2 gndio3
49 32117b?avr-03/11 at32uc3c 6.2 startup considerations this chapter summarizes the boot sequence of the at32uc3c. the behavior after power-up is controlled by the power manager. for specific details, refer to the power manager chapter. 6.2.1 starting of clocks at power-up, the bod33 and the bod18 are enabled. the device w ill be held in a reset state by the power-up circuitry, until the vddin_33 (resp. vddcore) has reached the reset threshold of the bod33 (resp bod18). refer to the electrical characteristics for the bod thresholds. once the power has stabilized, the device will use the system rc oscillator (rcsys, 115khz typical frequency) as clock source. the bod18 and bod33 are kept enabled or are disabled according to the fuse settings (see the fuse setting section in the flash controller chapter). on system start-up, the plls are disabled. all clocks to all modules are running. no clocks have a divided frequency, all parts of the system receive a clock with the same frequency as the inter- nal rc oscillator. 6.2.2 fetching of initial instructions after reset has been released, the avr32uc cpu st arts fetching instructions from the reset address, which is 0x8000_0000. this address points to the first address in the internal flash. the internal flash uses vddio voltage during read and write operations. it is recommended to use the bod33 to monitor this voltage and make sure the vddio is above the minimum level (3.0v). the code read from the internal flash is free to configure the system to use for example the plls, to divide the frequency of the clock routed to some of the peripherals, and to gate the clocks to unused peripherals.
50 32117b?avr-03/11 at32uc3c 7. power manager (pm) rev: 4.1.2.3 7.1 features ? generates clocks and resets for digital logic ? on-the-fly frequency change of cpu, hsb and pbx clocks ? sleep modes allow simple disabling of logic clocks and clock sources ? module-level clock gating through maskable peripheral clocks ? wake-up from internal or external interrupts ? automatic identificat ion of reset sources 7.2 overview the power manager (pm) provides synchronous clocks used to clock the main digital logic in the device, namely the cpu, and the modules and peripherals connected to the high speed bus (hsb) and the peripheral buses (pbx). the pm also contains advanced power-saving feat ures, allowing the user to optimize the power consumption for an application. the synchronous clocks are divided into a number of clock domains, one for the cpu and hsb and one for each pbx. the clocks can run at different speeds, so the user can save power by running pe ripherals at a relatively low clock, while main- taining a high cpu performance. additionally, the clocks can be independently changed on-the- fly, without halting any peripherals. this enables the user to adjust the speed of the cpu and memories to the dynamic load of the applicati on, without disturbing or re-configuring active peripherals. each module also has a separate clock, enabling t he user to switch off the clock for inactive modules, to save further pow er. additionally, clocks and os cillators can be automatically switched off during idle period s by using the sleep instruction on the cpu. the system will return to normal operation on occurrence of interrupts. the power manager also contains a reset contro ller, which collects all possible reset sources, generates hard and soft resets, and allows the reset source to be identified by software.
51 32117b?avr-03/11 at32uc3c 7.3 block diagram figure 7-1. pm block diagram 7.4 i/o lines description 7.5 product dependencies 7.5.1 interrupt the pm interrupt line is connected to one of the internal sources of the interrupt controller. using the pm interrupt requires the interrupt controller to be programmed first. 7.5.2 clock implementation in at32uc3c, the hsb shares the source clock with the cpu. this means that writing to the hsbsel register has no effect. this register will always read the same value as cpusel. the clock for the pm bus interface (clk_pm) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager, whoever if disabled it can only be re-enabled by a reset. table 7-1. i/o lines description name description type active level reset_n reset input low sleep controller synchronous clock generator reset controller main clock sources sleep instruction power-on detector resets synchronous clocks cpu, hsb, pbx interrupts external reset pin reset sources
52 32117b?avr-03/11 at32uc3c 7.6 functional description 7.6.1 synchronous clocks the system rc oscillator (rcsys) or a set of other clock sources provide the source for the main clock, which is the common root for the synchronous clocks for the cpu/hsb and pbx modules. for details about the other main clock sources, please refer to the register description of the main clock control register (mcctrl). the main clock is divided by an 8-bit prescaler, and each of these synchro nous clocks can run from any tapping of this prescaler, or the undi- vided main clock, as long as f cpu f pbx, . the synchronous clock source can be changed on-the fly, responding to varying load in the application. the clock domains can be shut down in sleep mode, as described in section 7.6.3 . additionally, the clocks for each module in each synchro- nous clock domain can be individually masked, to avoid power consumption in inactive modules. figure 7-2. synchronous clock generation 7.6.1.1 selecting the main clock source the common main clock can be connected to rcsys or a set of other cl ock sources. for details about the other main clock sources, please refer to the register description of the main clock control register (mcctrl). by default, the main clock will be connected to rcsys. the user can connect the main clock to an other source by writing the mcsel field in the mcctrl regis- ter. this must only be done after that unit has been enabled and is ready, otherwise a deadlock will occur. care should also be ta ken that the ne w frequency of the sync hronous clocks does not exceed the maximum frequency for each clock domain. 7.6.1.2 selecting synchronous clock division ratio the main clock feeds an 8-bit prescaler, which can be used to generate the synchronous clocks. by default, the synchronous clocks run on the undivided main clock. the user can select a pres- caler division for the cpu clock by writing cp udiv in cpusel register to one and cpusel in cpusel register to the value, resulting in a cpu clock frequency: f cpu = f main / 2 (cpusel+1) mask prescaler main clock sources mcsel 0 1 cpusel cpudiv main clock sleep controller cpumask cpu clocks hsb clocks pbx clocks sleep instruction
53 32117b?avr-03/11 at32uc3c similarly, the clock for the pbx can be divided by writing their respective registers. to ensure correct operation, frequencies must be selected so that f cpu f pbx . also, frequencies must never exceed the specified maximum frequency for each clock domain. cpusel and pbxsel can be written without halting or disabling peripheral modules. writing cpusel and pbxsel allows a new clock setting to be written to all synchronous clocks at the same time. it is possible to keep one or more clocks unchanged by writing a one to the registers. this way, it is possible to, e.g., scale cpu and hsb speed according to the required perfor- mance, while keeping the pbx frequency constant. for modules connected to the hsb bus, the pb clock frequency must be set to the same fre- quency as the cpu clock. 7.6.1.3 clock ready flag there is a slight delay from cpusel and pbxsel is written and the new clock setting becomes effective. during this interval, the clock ready (ckrdy) flag in isr will read as zero. if ckrdy in the ier register is written to one, the power manager interrupt can be triggered when the new clock setting is effective. cksel must not be re -written while ckrdy is zero, or the system may become unstable or hang. 7.6.2 peripheral clock masking by default, the clock for all modules are enabled, regardless of which modules are actually being used. it is possible to disable the clock for a module in the cpu, hsb or pbx clock domain by writing the corresponding bit in the clock mask register (cpu/hsb/pbx) to zero. when a module is not clocked, it will cease operation, and its registers cannot be read or written. the module can be re-enabled later by writing the corresponding mask bit to one. a module may be connected to several clock domains, in which case it will have several mask bits. the maskable module clocks table contains a list of implemented maskable clocks. 7.6.2.1 cautionary note note that clocks should only be switched off if it is certain that the module will not be used. switching off the clock for the flash controller will cause a problem if the cpu needs to read from the flash. switching off the clock to the power manager (pm), which contains the mask registers, or the correspond ing pbx bridge, will make it impossible to write the ma sk registers again. in this case, they can only be re-enabled by a system reset. 7.6.3 sleep modes in normal operation, all clock domains are active, allowing software execution and peripheral operation. when the cpu is idle, it is possible to switch off the cpu clock and optionally other clock domains to save power. this is activate d by the sleep instruction, which takes the sleep mode index number from table 7-2 on page 54 as argument. 7.6.3.1 entering and exiting sleep modes the sleep instruction will halt the cpu and all modules belonging to t he stopped clock domains. the modules will be halted regardless of th e bit settings of the mask registers. clock sources can also be switched off to save power. some of these have a relatively long start-up time, and are only switched off when very low power consumption is required.
54 32117b?avr-03/11 at32uc3c the cpu and affected modules are restarted when the sleep mode is exited. this occurs when an interrupt triggers. note that even if an interrupt is enabled in sleep mode, it may not trigger if the source module is not clocked. 7.6.3.2 supported sleep modes the following sleep modes are supported. these are detailed in table 7-2 on page 54 . ? idle: the cpu is stopped, the rest of the chip is operating. ? frozen: the cpu and hsb modules are stopped, peripherals are operating. ? standby: all synchronous clocks are stopped, but the clock sources are running, allowing quick wake-up to normal mode. ? stop: as standby, but oscillators, and other clock sources are stopped. 32khz (if enabled), rc oscillators, ast and wdt will still operate. ? deepstop: all synchronous clocks and clock sour ces are stopped. 32khz oscillator can run if enabled. rc oscillator still op erates. bandgap voltage refe rence and bod is turned off. ? static: all clock sources, including rc oscilla tor are stopped. 32khz oscillator can run if enabled. bandgap voltage reference and bod detector are turned off. note: 1. the sleep mode index corresponds to the argument to the sleep instruction. the power level of the internal voltage regulator is also adjusted according to the sleep mode to reduce the internal regulator power consumption. 7.6.3.3 waking from sleep modes there are two types of wake up sources from sleep, synchronous and asynchronous. synchro- nous wake up sources are any non-masked interrupt. asynchronous wake up sources are ast, wdt, external interrupts from eic, external resetor any asynchronous wake up enabled in the awen (asynchronous wake up enable) regist er. the valid wake up sources for each sleep mode is detailed in section 7-3 on page 54 . table 7-2. sleep modes index (1) sleep mode cpu hsb pbx gclk clock sources osc32 rcsys bod & bandgap voltag e regulator 0 idle stop run run run run run on normal mode 1 frozen stop stop run run run run on normal mode 2 standby stop stop stop run run run on normal mode 3 stop stop stop stop stop run run on low power mode 4 deepstop stop stop stop stop run run off low power mode 5 static stop stop stop stop run stop off low power mode table 7-3. wake up sources index (1) sleep mode wake up sources 0 idle synchronous, asynchronous 1 frozen synchronous (1) , asynchronous 2 standby asynchronous
55 32117b?avr-03/11 at32uc3c 7.6.3.4 precautions when entering sleep mode modules communicating with external circuits should normally be disabled before entering a sleep mode that will stop the mo dule operation. this prevents erra tic behavior when entering or exiting sleep mode. please refer to the re levant module documentation for recommended actions. communication between the synchronous clock domains is disturbed when entering and exiting sleep modes. this means that bus transactions are not allowed between clock domains affected by the sleep mode. the system may hang if th e bus clocks are stopped in the middle of a bus transaction. the cpu is automatically stopped in a safe state to ensure that all cpu bus operations are com- plete when the sleep mode goes into effect. thus, when entering idle mode, no further action is necessary. when entering a sleep mode (except idle mode), all hsb masters must be stopped before entering the sleep mode. also, if there is a chance that any pb write operations are incomplete, the cpu should perform a read operation from any register on the pb bus before executing the sleep instruction. this will stall the cpu while waiting for any pend ing pb operations to complete. 7.6.4 divided pb clocks the clock generator in the powe r manager provides di vided pbx clocks for use by peripherals that require a prescaled pbx clock. this is described in the documentation for the relevant modules. the divided clocks are directly maskable, and are stopped in sleep modes where the pbx clocks are stopped. 7.6.5 reset controller the reset controller collects the various reset sources in the system and generates hard and soft resets for the digital logic. the device contains a power-on detector, which keeps the system reset until power is stable. this eliminates the need for external reset circuitry to guarantee stable operation when powering up the device. it is also possible to reset the device by asse rting the reset_n pin. th is pin has an internal pull-up, and does not need to be driven externally when negated. table 7-4 on page 56 lists these and other reset sources supported by the reset controller. 3 stop asynchronous 4 deepstop asynchronous 5 static asynchronous (2) 1. only pb modules, as hsb modules have stopped clock. 2. wdt only if clocked from 32 khz oscillator. table 7-3. wake up sources index (1) sleep mode wake up sources
56 32117b?avr-03/11 at32uc3c figure 7-3. reset controller block diagram in addition to the listed reset types, the jtag & awire can keep parts of the device statically reset. see jtag and awire documentation for details. table 7-4. reset description when a reset occurs, some parts of the chip are not necessarily reset, depending on the reset source. only the power on reset (por) will force a reset of the whole ch ip. refer to the module configuration chapter to know the effect of the different reset events. the table located in the module configuration chapter lists parts of the device that are reset, depending on the reset source.the cause of the last reset can be read from the rcause regis- ter. this register contains one bit for each reset source, and can be read during the boot sequence of an application to determine the proper action to be taken. reset source description power-on reset supply voltage below the power-on reset detector threshold voltage external reset reset_n pin asserted brownout reset supply voltage on vddcore below the brownout reset detector threshold voltage cpu error caused by an illegal cpu access to external memory while in supervisor mode watchdog timer see watchdog timer documentation. ocd see on-chip debug documentation jtag reset controller reset_n power-on detector ocd watchdog reset rc_rcause cpu, hsb, pbx ocd, ast, wdt, clock generator brownout detector awire
57 32117b?avr-03/11 at32uc3c 7.6.5.1 power-on detector the power-on detector monitors the vddcore supply pin and generates a reset when the device is powered on. the reset is active until the supply voltage from the linear regulator is above the power-on threshold leve l. the reset will be re -activated if the vo ltage drops below the power-on threshold level. see electrical characteristics for parametric details. 7.6.5.2 external reset the external reset detector monitors the state of the reset_n pin. by default, a low level on this pin will generate a reset. 7.6.6 clock failure detector this mechanism allo ws switching the main cl ock to the safe rcsys clock, when the main clock source is considered off. this may happen when a external crystal is selected as the clock source of the main clock but the crystal is not mounted on the board. the mechanism is to detect, during a rcsys period, at least one ri sing edge of the main clock. if no rising edge is seen the clock is considered failed. example: * rcsys = 115khz => failure detected if the main clock is < 115 khz as soon as the dete ctor is enabled, the clock failure dete ctor will monitor the divided main clock. note that the detector does not monitor if the rcsys is the source of the main clock, or if the main clock is temporarily not available (startup-tim e after a wake-up, switching timing etc.), or in sleep mode where the main cl ock is driven by the rcsys (sto p and deepstop mode). when a clock failure is detected, the ma in clock automatically switches to the rcsys clock and the cfd interrupt is generated if enabled. the mcctrl register that select s the source clock of the main clock is changed by hardware to indicate that the main clock comes from rcsys. 7.6.7 interrupts the pm has a number of interrupts: ? ae: access error, set if a lock protected register is written without first being unlocked. ? ckrdy: clock ready, set when new cksel settings are effective. ? cfd: clock failure detected, set if the system detects that the main clock is not running.
58 32117b?avr-03/11 at32uc3c 7.7 user interface note: 1. the reset value is device specific. please re fer to the module configuration section at the end of this chapter. table 7-5. pm register memory map offset register name access reset state 0x0000 main clock control mcctrl read/write 0x00000000 0x0004 cpu clock select cpusel read/write 0x00000000 0x0008 hsb clock select hsbsel read only 0x00000000 0x000c pba clock select pbasel read/write 0x00000000 0x00010 pbb clock select pbbsel read/write 0x00000000 0x0014 pbc clock select pbcsel read/write 0x00000000 0x0020 cpu mask cpumask read/write 0x00000003 0x0024 hsb mask hsbmask read/write 0x00003fff 0x0028 pba mask pbamask read/write 0x07ffffff 0x002c pbb mask pbbmask read/write 0x0000007f 0x0030 pbc mask pbcmask read/write 0x000003ff 0x0040 pba divided mask pbadivmask read/write 0x0000007f 0x0044 pbb divided mask pbbdivmask read/write 0x0000007f 0x0048 pbc divided mask pbcdivmask read/write 0x0000007f 0x0054 clock failure detector control cfdctrl read/write 0x00000000 0x0058 unlock register unlock write only - 0x00c0 pm interrupt enable register ier write only 0x00000000 0x00c4 pm interrupt disable register idr write only 0x00000000 0x00c8 pm interrupt mask register imr read only 0x00000000 0x00cc pm interrupt status register isr read only 0x00000000 0x00d0 pm interrupt clear register icr write only 0x00000000 0x00d4 status register sr read only 0x00000000 0x0180 reset cause register rcause read only latest reset source 0x0184 wake cause register wcause read only latest wake source 0x0188 asynchronous wake enable awen read/write 0x00000000 0x03f8 configuration register config read only - (1) 0x03fc version register version read only - (1)
59 32117b?avr-03/11 at32uc3c 7.7.1 main clock control name: mcctrl access type: read/write offset: 0x0000 reset value: 0x00000000 ? mcsel: main clock select note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ----- mcsel table 7-6. main clocks in at32uc3c. mcsel[1:0] main clock source 0 system rc oscillator (rcsys) 1 oscillator 0 2 oscillator 1 3pll0 4pll1 5 8 mhz rc oscillator (rc8m) 6reserved 7 120 mhz rc oscillator (rc120m) others reserved
60 32117b?avr-03/11 at32uc3c 7.7.2 cpu clock select name: cpusel access type: read/write offset: 0x0004 reset value: 0x00000000 ? cpudiv, cpusel: cpu divi sion and clock select ? cpudiv = 0: cpu clock equals main clock. ? cpudiv = 1: cpu clock equals main clock divided by 2 (cpusel+1) . note that if cpudiv is written to 0, cpusel should also be written to 0 to ensure correct operation. also note that writing this register clears poscsr:ckrdy. the register mu st not be re-written until ckrdy goes high. note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 cpudiv - - - - cpusel
61 32117b?avr-03/11 at32uc3c 7.7.3 hsb clock select name: hsbsel access type: read only offset: 0x0008 reset value: 0x00000000 this register is read-only and it s content is alwa ys equal to cpu_sel 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 hsbdiv - - - - hsbsel
62 32117b?avr-03/11 at32uc3c 7.7.4 pbx clock select name: pbxsel access type: read/write offset: 0x000c, 0x0010, 0x0014 reset value: 0x00000000 ? pbdiv, pbsel: pbx division and clock select ? pbdiv = 0: pbx clock equals main clock. ? pbdiv = 1: pbx clock equals main clock divided by 2 (pbsel+1) . note that if pbdiv is written to 0, pbsel should also be written to 0 to ensure correct operation. also note that writing this register clears poscsr:ckrdy. the register mu st not be re-written until ckrdy goes high. note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 pbdiv - - - - pbsel
63 32117b?avr-03/11 at32uc3c 7.7.5 clock mask name: cpu/hsb/pba/pbbmask access type: read/write offset: 0x0020, 0x0024, 0x0028, 0x002c, 0x0030 reset value: - ? mask: clock mask ? if bit n is cleared, the clock for module n is stopped. if bit n is set, the clock for module n is enabled according to the cu rrent power mode. the number of implemented bits in each mask regist er, as well as which module clock is controlled by each bit, is shown in table 7-7 . 31 30 29 28 27 26 25 24 mask[31:24] 23 22 21 20 19 18 17 16 mask[23:16] 15 14 13 12 11 10 9 8 mask[15:8] 76543210 mask[7:0] table 7-7. maskable module clocks in at32uc3c. bit cpumask hsbmask pbamask pbbmask pbcmask 0 - sau intc flashc pdca 1 ocd pdca pm usbc mdma 2 - mdma scif hmatrix usart1 3 - usbc ast sau spi0 4 - canif wdt smc canif 5 - hflashc eic sdramc tc0 6 - pba bridge freqm macb adcifa 7 - pbb bridge gpio - usart4 8 - pbc bridge usart0 - twim2 9 - hsb ram usart2 - twis2 10 - ebi usart3 - - 11 - macb spi1 - - 12 - pevc twim0 - -
64 32117b?avr-03/11 at32uc3c note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. 13 - - twim1 - - 14 - - twis0 - - 15 - - twis1 - - 16 - - iisc - - 17 - - pwm - - 18 - - qdec0 - - 19 - - qdec1 - - 20 - - tc1 - - 21 - - pevc - - 22 - - acifa0 - - 23 - - acifa1 - - 24 - - dacifb0 - - 25 - - dacifb1 - - 26 - - aw - - 31:27 - - - - - table 7-7. maskable module clocks in at32uc3c. bit cpumask hsbmask pbamask pbbmask pbcmask
65 32117b?avr-03/11 at32uc3c 7.7.6 divided clock mask name: pbadivmask/pbbdivmask/pbcdivmask access type: read/write offset: 0x0040, 0x0044, 0x0048 reset value: - ? mask: clock mask if bit n is written to zero, the clock divided by 2 (n+1) is stopped. if bit n is written to one, the clock divided by 2 (n+1) is enabled according to the current power mode. table 7-8 and table 7-9 show what clocks are affect ed by the different mask bits. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - ------ 15 14 13 12 11 10 9 8 -------- 76543210 - mask[6:0] table 7-8. pba divided clock mask bit usart0 usart2 usart3 tc1 0 - timer1_clock2 1- - 2 clk_pba_usart_div timer1_clock3 3- - 4 - timer1_clock4 5- - 6 - timer1_clock5 table 7-9. pbc divided clock mask bit usart1 usart4 tc0 0 - timer0_clock2 1- - 2 clk_pbc_usart_div timer0_clock3 3- -
66 32117b?avr-03/11 at32uc3c note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. 4 - timer0_clock4 5- - 6 - timer0_clock5 table 7-9. pbc divided clock mask bit usart1 usart4 tc0
67 32117b?avr-03/11 at32uc3c 7.7.7 clock failure detector control register name: cfdctrl access type: read/write offset: 0x0054 reset value: 0x00000000 ? sfv: store final value ? 0: the register is read/write ? 1: the register is read-only, to protect against further accidental writes. ? cfden: clock failure detection enable ? 0: clock failure detector is disabled ? 1: clock failure detector is enabled note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. 31 30 29 28 27 26 25 24 sfv------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------ cfden
68 32117b?avr-03/11 at32uc3c 7.7.8 pm unlock register name: unlock access type: write-only offset: 0x0058 reset value: - to unlock a write protected register, first write to the unlock register with the address of the register to unlock in the addr field and 0xaa in the key field. then, in the next pb access write to the register specified in the addr field. ? key: unlock key ? write this bit field to 0xaa to enable unlock. ? addr: unlock address ? write the address of the register to unlock to this bit field. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------ addr[9:8] 76543210 addr[7:0]
69 32117b?avr-03/11 at32uc3c 7.7.9 interrupt enable register name: ier access type: write-only offset: 0x0c0 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - ckrdy - - - - cfd
70 32117b?avr-03/11 at32uc3c 7.7.10 interrupt disable register name: idr access type: write-only offset: 0x0c4 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - ckrdy - - - - cfd
71 32117b?avr-03/11 at32uc3c 7.7.11 interrupt mask register name: imr access type: read-only offset: 0x0c8 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - ckrdy - - - - cfd
72 32117b?avr-03/11 at32uc3c 7.7.12 interrupt status register name: isr access type: read-only offset: 0x0cc reset value: 0x00000000 0: the corresponding interrupt is cleared. 1: the corresponding interrupt is pending. this bit is cleared when the corresponding bit in icr is written to one. this bit is set when the corresponding interrupt occurs. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - ckrdy - - - - cfd
73 32117b?avr-03/11 at32uc3c 7.7.13 interrupt clear register name: icr access type: write-only offset: 0x0d0 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in isr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - ckrdy - - - - cfd
74 32117b?avr-03/11 at32uc3c 7.7.14 status register name: sr access type: read-only offset: 0x0d4 reset value: 0x00000000 ? ae: access error 0: no access error has occured. 1: a write to lock protected regist er without unlocking it has occured. ? ckrdy: clock ready 0: the cksel register has been written, and the new clock setting is not yet effective. 1: the synchronous clocks have frequencies as indicated in the cksel register. ? cfd: clock failure detected 0: main clock is running correctly. 1: failure on main clock detected. main clock is now running on rc osc. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - ckrdy - - - - cfd
75 32117b?avr-03/11 at32uc3c 7.7.15 reset cause name: rcause access type: read-only offset: 0x0180 reset value: latest reset source ? bod33: brown-out 3.3v reset the cpu was reset due to the supply voltage being lower than the 3.3v supply monitor (bod33) threshold level. ? awire: awire reset the cpu was reset by the awire ? ocdrst: ocd reset the cpu was reset because the res strobe in the ocd development control register has been written to one. ? cpuerr: cpu error the cpu was reset because had detected an illegal access. ? jtag: jtag reset the chip was reset by the jtag system reset. ? wdt: watchdog reset the cpu was reset because of a watchdog time-out. ? ext: external reset pin the cpu was reset due to t he reset pin being asserted. ? bod: brown-out reset the cpu was reset due to the core supply voltage being lower than the brown-out threshold level. ? por: power-on reset the cpu was reset due to the core supply voltage being lower than the power-on threshold level, or due to the input voltage being lower than the minimum required input voltage for the voltage regulator. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - bod33 - awire - - ocdrst 76543210 cpuerr - jtag wdt ext bod por
76 32117b?avr-03/11 at32uc3c 7.7.16 wake cause register register name wcause register access read-only offset: 0x0184 reset value: latest reset source ? a bit in this register is set on wake up caused by the peripheral referred to in table 7-10 . 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------ wcause[17:16] 15 14 13 12 11 10 9 8 wcause[15:8] 76543210 wcause[7:0] table 7-10. wake cause bit wake cause 1 usbc 1 canif-rxline[0] 2 canif-rxline[1] 3- 4twi slave 0 5twi slave 1 6twi slave 2 15:7 - 16 eic 17 ast 31:18 -
77 32117b?avr-03/11 at32uc3c 7.7.17 asynchronous wake up enable register register name awen register access read/write offset: 0x0188 reset value: 0x00000000 each bit in this register corresponds to an asynchronous wake up, according to table 7-11 . 0: the corresponding wake up is disabled. 1: the corresponding wake up is enabled 31 30 29 28 27 26 25 24 awen[31:24] 23 22 21 20 19 18 17 16 awen[23:16] 15 14 13 12 11 10 9 8 awen[15:8] 76543210 awen[7:0] table 7-11. asynchronous wake up bit asynchronous wake up 0 usbwen 1 canif0wen 2 canif1wen 3- 4 twis0wen 5 twis1wen 6 twis2wen 31:7 -
78 32117b?avr-03/11 at32uc3c 7.7.18 configuration register name: config access type: read-only offset: 0x03f8 reset value: 0x000000c3 this register shows the configuration of the pm. ? hsbpevc:hsb pevc clock implemented 0: hsbpevc not implemented. 1: hsbpevc implemented. ? pbd: pbd implemented 0: pbd not implemented. 1: pbd implemented. ? pbc: pbc implemented 0: pbc not implemented. 1: pbc implemented. ? pbb: pbb implemented 0: pbb not implemented. 1: pbb implemented. ? pba: pba implemented 0: pba not implemented. 1: pba implemented. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 hsbpevc - - pbd pbc pbb pba
79 32117b?avr-03/11 at32uc3c 7.7.19 version register name: version access type: read-only offset: 0x03fc reset value: 0x00000410 ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
80 32117b?avr-03/11 at32uc3c 7.8 module configuration the specific configuration for ea ch pm instance is listed in t he following tables. the module bus clocks listed here are connecte d to the system bus clocks. pleas e refer to the power manager chapter for details. table 7-12. module clock name module name clock name description pm clk_pm peripheral bus clock from the pba clock domain table 7-13. register reset values register reset value config 0x00000087 version 0x00000412 table 7-14. effect of the different reset events power-on reset external reset watchdog reset 1.8v bod reset 3.3v bod reset cpu error reset ocd reset jtag reset awire reset cpu/hsb/pbx (excluding power manager) y y y yyy yyy 32 khz oscillator y n n n n n n n n ast registers, except interrupt registers y n n nnn nnn gplp registers y n n n n n n n n watchdog control register y y n y y y y y y voltage regulator calibration register y n n nnn nnn rcsys calibration register y n n n n n n n n 1.8v bod control register y y y n y y y y y 3.3v bod control register y y y y n y y y y bandgap control register y y y n y y y y y clock control registers y y y y y y y y y osc control registers y y y yyy yyy ocd system a nd ocd registers y y n y y y n y y
81 32117b?avr-03/11 at32uc3c 8. system control interface (scif) rev: 1.0.2.0 8.1 features ? controls integrated oscillators and plls ? supports 2x general purpose cr ystal oscillators, 0.4mhz-20mhz ? supports 2x phase-locked-loop, 80-240 mhz ? supports 32 khz low power oscillator (osc32k) ? integrated 115khz rc oscillator (rcsys) ? controls 8 mhz / 1 mhz integr ated rc oscillator (rc8m) ? controls 120 mhz integrat ed rc oscillator (rc120m) ? generic clocks with wide frequency range provided ? controls bandgap voltage reference through control and calibration registers ? controls brown-out detectors and supply monitors ? controls voltage regulator behavior and calibration ? two 32-bit general purpose low power registers 8.2 description the system control interface (s cif) controls the oscillators, pll, generic clocks, bods, the voltage regulators and general purpose low power registers. 8.3 i/o lines description 8.4 product dependencies 8.4.1 i/o lines the scif provides a number of generic clock outputs, which can be connected to output pins, multiplexed with gpio lines. the programmer must first program the gpio controller to assign these pins to their peripheral function. if the i/o pins of the scif are not used by the application, they can be used for other purposes by the gpio controller. oscillators pi ns are also multiplexed with gpio. when osc illators are used, the related pins are controlled directly by the scif, over- riding gpio settings. table 8-1. i/o lines description pin name pin description type xin0 crystal 0 input analog/digital xin1 crystal 1 input analog/digital xin32 crystal 32 input analog/digital xout0 crystal 0 output analog xout1 crystal 1 output analog xout32 crystal 32 output analog gclk[1:0] generic clock output digital
82 32117b?avr-03/11 at32uc3c 8.4.2 interrupt the scif interrupt line is connected to one of the internal sources of the interrupt controller. using the scif interrupt requires the interrupt controller to be programmed first. 8.4.3 debug operation the scif module does not interact with debug operations. 8.4.4 clocks the scif controls all oscillators on the part. those oscillators can then be used as sources for for generic clocks (handled by the scif) and for the cpu and peripherals (i n this case, selection of source is done by the power manager). 8.5 functional description 8.5.1 oscillator operation the main oscillator is designed to be used with an external 0.4 to 20mhz crystal and two biasing capacitors, as shown in figure 8-1 . the oscillator can be used for the main clock in the device, as described in the power manager chapter . the oscillator can be used as source for the generic clocks, as described in ?generic clocks? on page 84 . the oscillator is disabled by de fault after reset. wh en the oscillator is disabled, the xin and xout pins can be used as general purpose i/os. when the oscillator is configured to use an external clock, the clock must be applied to t he xin pin while the xout pin can be used as a general purpose i/o. the oscillator can be enabl ed by writing a one to the osce n bit in oscctrln. operation mode (external clock or crysta l) is chosen by writing to the mode field in oscctrln. the oscillator is automatically switched off in certain sleep modes to reduce power consumption, as described in the power manager chapter. after a hard reset, or when waking up from a sleep mode that disa bled the oscillator, the oscilla- tor may need a certain amount of time to stabilize on the corr ect frequency. this start-up time can be set in the oscctrln register. the scif masks the oscilla tor outputs during the st art-up time, to ensure that no unstable clocks propagate to the digital logic. the oscnrdy bits in pclksr are automatically set and cleared according to the status of the oscillators. a zero to one transition on these bits can also be con- figured to generate an interrupt, as described in ?interrupts? on page 88 .
83 32117b?avr-03/11 at32uc3c figure 8-1. oscillator connections 8.5.2 32khz oscillator (osc32k) operation the 32khz oscillator (osc32k) operates as described for the oscillator above. the 32khz oscillator is used as source clock for the asynchronous timer and the watchdog timer. the 32khz oscillator can be used as source for the generic clocks, as described in ?generic clocks? on page 84 . the oscillator is disabled by default, but can be enabled by writing a one to the osc32en bit in oscctrl32. the oscillator is an ultra-low power design and remains enabled in all sleep modes. while the 32khz oscillator is disabled, the xin3 2 and xout32 pins are available as general purpose i/os. when the oscillator is configured to work with an external clock (mode field in oscctrl32 register), the external clock must be connected to xin32 while the xout32 pin can be used as a general purpose i/o. the startup time of the 32khz oscillator can be set in the oscctrl32, after which osc32rdy in pclksr is set. an interrupt can be generated on a zero to one transition of osc32rdy. as a crystal oscillator usually requires a very long startup time (up to 1 second), the 32 khz oscillator will keep running across resets, except power-on-reset. the 32khz oscillator is not controlled by the sl eep controller, and will run in all sleep modes if enabled. 8.5.3 pll operation the device contains two plls, pll0 and pll1. these are disabled by default, but can be enabled to provide high frequency source clocks for synchronous or generic clocks. the plls can take either oscillator 0, os cillator 1 or 8mhz rc oscillator (rc8m) as reference clock. the pll output is divided by a multiplication factor, and the pll compares the resulting clock to the reference clock. the pll will adju st its output frequency unt il the two compared clocks are equal, thus locking the output frequency to a multiple of the reference clock frequency. when the pll is switched on, or when changing the clock source or multiplication factor for the pll, the pll is unlocked and the output frequency is undefined. the pll clock for the digital logic is automatically masked when the pll is unlocked, to prevent connected digital logic from receiving a too high frequency and thus becoming unstable. xin xout c lext c lext c i c l uc3c
84 32117b?avr-03/11 at32uc3c figure 8-2. pll with control logic and filters 8.5.3.1 enabling the pll plln is enabled by writing a one to the pllen bi t in the plln register. pllosc selects oscilla- tor 0 or 1 as clock source. the pllmul and plldiv bit fields must be written with the multiplication and division factors. the plln.pllopt field should be set to proper values according to the pll operating fre- quency. the pllopt field can also be set to divide the output frequency of the plls by 2. the lock signal for each pll is available as a lockn flag in poscsr. an interrupt can be gen- erated on a 0 to 1 transition of these bits. 8.5.4 generic clocks timers, communication modules, and other modules connected to external circuitry may require specific clock frequencies to operate correctly. the scif contains an implementation defined number of generic clocks that can provide a wide range of accurate clock frequencies. each generic clock module runs from either clock source listed in ?generic clock source? on page 118 . the selected source can optionally be divided by any even integer up to 512. each clock can be independently enabled and disabled, and is also automatically disabled along with peripheral clocks by the sleep controller in the power manager. pll output divider 0 1 osc0 clock osc1 clock pllosc pllen pllopt pllmul lock mask pll clock input divider f in plldiv
85 32117b?avr-03/11 at32uc3c figure 8-3. generic clock generation 8.5.4.1 enabling a generic clock a generic clock is enabled by writing a one to the cen bit in gcctrl to one. each generic clock can individually select a clock source by setting the oscsel bits. the source clock can option- ally be divided by writing a one to diven and the division factor to div, resulting in the output frequency: f gclk = f src / (2*(div+1)) 8.5.4.2 disabling a generic clock the generic clock can be disabled by writing a zero to cen or entering a sleep mode that dis- ables the pb clocks. in either ca se, the generic clock will be swit ched off on the first falling edge after the disabling event, to ensure that no glitches occur. if cen is written to zero, the bit will still read as one until the next falling edge occurs, and the clock is actually switched off. when writ- ing a zero to cen, the other bits in gcctrl should not be changed until cen reads as zero, to avoid glitches on the generic clock. when the clock is disabled, both the prescaler and output are reset. 8.5.4.3 changing clock frequency when changing generic clock frequency by writing gcctrl, the clock should be switched off by the procedure above, before being re-enabled with the new clock source or division setting. this prevents glitches during the transition. 8.5.4.4 generic clock implementation in at32uc3c, the generic clocks are alloca ted to different functions as shown in table 8-2 . divider oscsel generic clock div 0 1 diven mask cen sleep controller table 8-2. generic clock allocation clock number function name 0 usb clock (48 mhz) gclk_usbc 1 canif gclk_canif 2 ast gclk_ast
86 32117b?avr-03/11 at32uc3c 8.5.5 1.8v brown out detection (bod18) the 1.8v brown-out detector (bod18) monitors the vddcore supply pin and compares the supply voltage to the brown-ou t detection level, as set in bod.level. the bod18 is disabled by default, but can be enabled either by software or by flash fuses. the 1.8v brown-out detec- tor can either generate an interrupt or a reset when the supply voltage is below the brown-out detection level. in any case, the bod18 output value is given by the pclksr.boddet bit. note that any change to the bod.level field of the bod regi ster should be done with the bod18 deactivated to avoid spur ious reset or interrupt. when turned-on, th e bod18 output will be masked during one half of a rcsys clock cycle and two main clocks cycles to avoid false results. if the jtag or the awire is enabled, th e bod18 reset and in terrupt will be masked. see electrical characterist ics for parametric details. although it is not recomme nded, it is still possible to override the default factory settings by writ- ing to those registers. to prevent unexpected writes due to software bugs, write access to this register is protected by a locking mechanism, for details please refer to the unlock register description. 8.5.6 3.3v brown out detection (bod33) the 3.3v brown-out detector (bod33) monito rs the vddin_5 supply pin and compares the supply voltage to the brown-out detection level, as set in bo d33.level. the bod33 is disabled by default, but can be enabled by software or by flash fuses. the 3.3v brown-out detector can generate an interrupt or a reset when the supply voltage is below the brown-out detection level. in any case, the bod33 value is given by the pclksr.bod33det bit. note that any change to the bo d33.level field of the bod33 regi ster should be done with the bod33 deactivated to avoid spurious interrupt. when turned-on, the bod33 output will be masked during one half of a rcsys clock cycle and two main clocks cycles to avoid false results. 3- 4 pwm gclk_pwm 5 qdec0 gclk_qdec0 6 qdec1 gclk_qdec1 7 gclk event, mapped to event number 16. see the module configuration of pevc for more details. 8 gclk event, mapped to event number 17. see the module configuration of pevc for more details. 9 gclk[0] output pin 10 gclk[1] output pin 11 iisc gclk_iisc table 8-2. generic clock allocation clock number function name
87 32117b?avr-03/11 at32uc3c if the jtag or the awire is enabled, th e bod33 reset and in terrupt will be masked. see electrical characterist ics for parametric details. to prevent unexpected writes due to software bugs, write access to this register is protected by a locking mechanism, for details please refer to the unlock register description. 8.5.7 5v brown out detection (bod50) the 5v brown-out detector (bod50) monitors the vddin_5 supply pin and compares the sup- ply voltage to the brown-out detection level, as set in bod50.level. the bod50 is disabled by default, but can be enabled by software. the 5v brown-out detector can generate an interrupt when the supply voltage is below the brown-out detection level. in any case, the bod50 output value is given by the pclksr.bod50det bit. note that any change to the bo d50.level field of the bod50 regi ster should be done with the bod50 deactivated to avoid spurious interrupt. when turned-on, the bod50 output will be masked during one half of a rcsys clock cycle and two main clocks cycles to avoid false results. if the jtag or the awire is enabl ed, the bod50 interrupt will be masked. see electrical characterist ics for parametric details. to prevent unexpected writes due to software bugs, write access to this register is protected by a locking mechanism, for details please refer to the unlock register description. 8.5.8 bandgap the flash memory, the brown-out detectors need a stable voltage reference to operate. this reference voltage is provided by an internal bandgap voltage reference. this reference is auto- matically turned on at star tup and turned off during deepst op and static sleep modes to save power. the bandgap voltage reference is calibrated through the bgcr.calib field. this field is loaded after a power on reset with default values stored in factory-programmed flash fuses. it is not recommended to override default factory settings as it may prevent correct operation of the flash and bods. to prevent unexpected writes due to software bugs, write access to this register is protected by a locking mechanism, for details please refer to the unlock register description. 8.5.9 voltage regulators the embedded 1.8v regulator provides the core supply. the embedded 3.3v voltage regulator is used to supply the usb pads. both regulators are turned on at startup. if the application is supplied with a voltage r ange around 3.3v or the application does not use the usb interface, the 3.3v voltage regulator has to be turned off by writing 11 binary to vregctrl.vreg33ctl. the 1.8v voltage regulator has its own voltage reference that is calibrated through the vregcr.calib field. this fiel d is loaded after a power on reset with default values stored in factory-programmed flash fuses. although it is not recomme nded, it is still possible to override the default factory settings by writ- ing to those registers. to prevent unexpected writes due to software bugs, write access to this register is protected by a locking mechanism, for details please refer to the unlock register description.
88 32117b?avr-03/11 at32uc3c 8.5.10 system rc oscillator (rcsys) the system rc oscillator (rcsys) has a 3 cycles star tup time, and is always available except in the static sleep mode. the system rc oscillator operates at a nominal frequency of 115 khz, and is calibrated using the rccr.calib calibr ation field. after a power on reset, the rccr.calib field is loaded with a factory defined value stored in the flash fuses. although it is not recomme nded, it is still possible to override the default factory settings by writ- ing to the rccr.calib field. to prevent unexpected writes due to software bugs, write access to this register is protected by a locking mechanism, for details please refer to the unlock reg- ister description. 8.5.11 8mhz / 1mhz rc oscillator (rc8m) the 8mhz / 1mhz rc oscillator (rc8m) operat es at a nominal frequency of 8mhz or 1 mhz according to rccr8.freqmode bit. it is ca librated using the rccr8.calib calibration field. after a power on reset, the rccr8.calib field is automatically loaded with the rc8m_calib field of the oscillator calibration register , a factory defined value stored in the factory page of the flash. if the user wants to run the osc illator at 1mhz or if the device operates at vddin_5 within the 5v range, it has to write the rccr8 .calib field with the corresponding field from the oscillator cal- ibration register. although it is not recomme nded, it is still possible to override the default factory settings by writ- ing to the rccr8.calib field. to prevent unexpect ed writes due to software bugs, write access to this register is protected by a locking mechanism, for details please refer to the unlock reg- ister description. 8.5.12 rc120m the 120mhz rc oscillator can be used for the main clock in the device, as described in the power manager chapter. to enable the clock, the user must write a one to the en bit in the rc120mcr register, and read back the rc120mcr register until the en bit reads one. the clock is disabled by writing a zero to the en bit. the oscillator is automatically sw itched off in certain sleep mode s to reduce po wer consumption, as described in the power manager chapter. 8.5.13 general purpose low power registers (gplp) the gplp registers are 32-bit registers that are reset only by power-on-reset. user software can use these registers to save context variables in a very low power mode. 8.5.14 interrupts the scif has separate interrupt requests: ? ae - access error: ? set when a protected scif register was accessed without first being correctly unlocked. ? pll1locklost - pll1 lock lost: ? set when a 0 to 1 transition on the pclksr.pll1locklost bit is detected. ? pll0locklost - pll0 lock lost: ? set when a 0 to 1 transition on the pclksr.pll0locklost bit is detected.
89 32117b?avr-03/11 at32uc3c ? bod50det - 5v brown out detection: ? set when a 0 to 1 transition on the pclksr.bod50det bit is detected. ? bod33det - 3.3v brown out detection: ? set when a 0 to 1 transition on the pclksr.bod33det bit is detected. ? boddet - 1.8v brown out detection: ? set when a 0 to 1 transition on the pclksr.boddet bit is detected. ? pll1lock - pll1 locked: ? set when a 0 to 1 transition on th e pclksr.pll1lock bit is detected. ? pll0lock - pll0 locked: ? set when an 0 to 1 transition on the pclksr.pll0lock bit is detected. ? rcosc8mrdy - 8mhz / 1mhz rcosc ready: ? set when a 0 to 1 transition on the pclksr.rcosc8mrdy bit is detected. ? osc32rdy - 32khz oscillator ready: ? set when a 0 to 1 transition on the pclksr.osc32rdy bit is detected. ? oscr1dy - osc1 ready: ? set when a 0 to 1 transition on the pclksr.osc1rdy bit is detected. ? oscr0dy - osc0 ready: ? set when a 0 to 1 transition on the pclksr.osc0rdy bit is detected. this allows the user to allocate separate handlers and priorities to the different interrupt types. the interrupt request will be generated if the corresponding bit in the interrupt mask register (imr) is set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier), and cleared by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt request remains active until the corresponding bit in the interrupt status register (isr) is cleared by writing a one to the corresponding bit in the interrupt clear register (icr).
90 32117b?avr-03/11 at32uc3c 8.6 user interface table 8-3. scif register memory map offset register register name access reset 0x0000 interrupt enable register ier write-only 0x00000000 0x0004 interrupt disable register idr write-only 0x00000000 0x0008 interrupt mask register imr read-only 0x00000000 0x000c interrupt status register isr read-only 0x00000000 0x0010 interrupt clear register icr write-only 0x00000000 0x0014 power and clocks status r egister pclksr read-only 0x00000000 0x0018 unlock register unlock write-only 0x00000000 0x001c pll0 control register pll0 read/write 0x00000000 0x0020 pll1 control register pll1 read/write 0x00000000 0x0024 oscillator0 control register oscctrl0 read/write 0x00000000 0x0028 oscillator1 control register oscctrl1 read/write 0x00000000 0x002c 1.8v bod control register bod read/write 0x00000000 0x0030 bandgap calibration register bgcr read/write 0x00000000 0x0034 3.3v bod control register bod33 read/write 0x00000000 0x0038 5v bod control register bod50 read/write 0x00000000 0x003c voltage regulator calibration register vregcr read/write 0x00000000 0x0040 voltage regulator control register vregctrl read/write 0x00000000 0x0044 rcsys calibration register rccr read/write 0x00000000 0x0048 8mhz / 1 mhz rc oscillator control register rccr8 read/write 0x00000000 0x004c oscillator 32 control register oscctrl32 read/write 0x00000000 0x0058 120mhz rc oscillator control register rc120mcr read/write 0x00000000 0x005c general purpose low power register 0 gplp0 read/write 0x00000000 0x0060 general purpose low power register 1 gplp1 read/write 0x00000000 0x0064-0x008c generic clock control gcctrl read/write 0x00000000 0x03c8 pll interface version register pllversion read-only - (1) 0x03cc oscillator 0/1 interface ve rsion register oscversion read-only - (1) 0x03d0 1.8v bod interface version register bodversion read-only - (1) 0x03d4 3.3/5.0v bod interface version register bodbversion read-only - (1) 0x03d8 voltage regulator interface version register vregversion read-only - (1) 0x03dc rcsys interface version register rccrversion read-only - (1) 0x03e0 8mhz/1mhz rcosc interface ve rsion register rccr8version read-only - (1) 0x03e4 32 khz oscillator interface version register osc32version read-only - (1) 0x03f0 120mhz rc oscillator interface version register rc120mversion read-only - (1)
91 32117b?avr-03/11 at32uc3c note: 1. the reset value is device specific. please re fer to the module configuration section at the end of this chapter. 0x03f4 gplp version regist er gplpversion read-only - (1) 0x03f8 generic clock version register gclkversion read-only - (1) 0x03fc scif version register version read-only - (1) table 8-3. scif register memory map offset register register name access reset
92 32117b?avr-03/11 at32uc3c 8.6.1 interrupt enable register name: ier access type: write-only offset: 0x0000 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 ae--- - --- 23 22 21 20 19 18 17 16 ---- - --- 15 14 13 12 11 10 9 8 ---- - pll1_lock lost pll0_lock lost bod50det 7654 3 210 bod33det boddet pll1_lock pll0_lock rcosc8mrdy osc32rdy osc1rdy osc0rdy
93 32117b?avr-03/11 at32uc3c 8.6.2 interrupt disable register name: idr access type: write-only offset: 0x0004 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----- pll1_lock lost pll0_lock lost bod50det 76543210 bod33det boddet pll1_lock pll0_lock rcosc8mr dy osc32rdy osc1rdy osc0rdy
94 32117b?avr-03/11 at32uc3c 8.6.3 interrupt mask register name: imr access type: read-only offset: 0x0008 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----- pll1_lock lost pll0_lock lost bod50det 76543210 bod33det boddet pll1_lock pll0_lock rcosc8mr dy osc32rdy osc1rdy osc0rdy
95 32117b?avr-03/11 at32uc3c 8.6.4 interrupt status register name: isr access type: read-only offset: 0x000c reset value: 0x00000000 0: the corresponding interrupt is cleared. 1: the corresponding interrupt is pending. this bit is cleared when the corresponding bit in icr is written to one. this bit is set when the corresponding interrupt occurs. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----- pll1_lock lost pll0_lock lost bod50det 76543210 bod33det boddet pll1_lock pll0_lock rcosc8mr dy osc32rdy osc1rdy osc0rdy
96 32117b?avr-03/11 at32uc3c 8.6.5 interrupt clear register name: icr access type: write-only offset: 0x0010 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in isr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----- pll1_lock lost pll0_lock lost bod50det 76543210 bod33det boddet pll1_lock pll0_lock rcosc8mr dy osc32rdy osc1rdy osc0rdy
97 32117b?avr-03/11 at32uc3c 8.6.6 power and clocks status register name: pclksr access type: read-only offset: 0x0014 reset value: 0x00000000 ? ae: scif access error 0: no access error has occurred on the scif. 1: an access error has occurred on the scif. ? plll1_locklost: pll1 lock lost value 0: pll1 has not lost its lock or has never been enabled. 1: pll1 has lost its lock, either by disabling the pll1 or due to faulty operation. ? plll0_locklost: pll0 lock lost value 0: pll0 has not lost its lock or has never been enabled. 1: pll0 has lost its lock, either by disabling the pll0 or due to faulty operation. ? bod50det: 5.0v brown out detection 0: bod50 not enabled or the 5.0v powe r supply is above the bod50 threshold. 1: bod50 enabled and the 5.0v power supply is going below bod50 threshold. ? bod33det: 3.3v brown out detection 0: bod33 not enabled or the 3.3v powe r supply is above the bod33 threshold. 1: bod33 enabled and the 3.3v power supply is going below bod33 threshold. ? boddet: 1.8v brown out detection 0: bod18 not enabled or the 1.8v powe r supply is above the bod18 threshold. 1: bod18 enabled and the 1.8v power supply is going below bod18 threshold. ? pll1_lock: pll1 locked on accurate value 0: pll1 is unlocked on accurate value. 1: pll1 is locked on accurate value, and is ready to be selected as clock source with an accurate output clock. ? pll0_lock: pll0 locked on accurate value 0: pll0 is unlocked on accurate value. 1: pll0 is locked on accurate value, and is ready to be selected as clock source with an accurate output clock. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----- pll1_lock lost pll0_lock lost bod50det 76543210 bod33det boddet pll1_lock pll0_lock rcosc8mr dy osc32rdy osc1rdy osc0rdy
98 32117b?avr-03/11 at32uc3c ? rcosc8mrdy: 8mhz / 1mhz rcosc ready 0: 8mhz / 1mhz rc oscillato r not enabled or not ready. 1: 8mhz / 1mhz rc oscillator is stable and ready to be used as clock source. ? osc32rdy: 32 khz oscillator ready 0: oscillator 32 not enabled or not ready. 1: oscillator 32 is stable and ready to be used as clock source. ? osc1rdy: osc1ready 0: oscillator not enabled or not ready. 1: oscillator is stable and ready to be used as clock source. ? osc0rdy: osc0ready 0: oscillator not enabled or not ready. 1: oscillator is stable and ready to be used as clock source.
99 32117b?avr-03/11 at32uc3c 8.6.7 unlock register name: unlock access type: write-only offset: 0x0018 reset value: 0x00000000 to unlock a write protected register, first write to the unlock r egister with the address of the re gister to unlock in the addr field and 0xaa in the key field. then, in the next pb ac cess write to the register specified in the addr field. ? key: unlock key write this bit field to 0xaa to enable unlock. ? addr: unlock address write the address of the register to unlock to this field. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------ addr[9:8] 76543210 addr[7:0]
100 32117b?avr-03/11 at32uc3c 8.6.8 pll control register name: pll0,1 access type: read/write offset: 0x001c,0x0020 reset value: 0x00000000 ? pllcount: pll count specifies the number of slow clock cycles before isr.lockn is set after plln has been written, or after plln has been automatically re-enabled after exiting a sleep mode. ? pllmul: pll multiply factor ? plldiv: pll division factor these fields determine the ratio of the output frequency of the internal vco of the pll (f vco ) to the source oscillator frequency: f vco = (pllmul+1) / (plldiv) * f osc if plldiv > 0 f vco = 2 * (pllmul+1) * f osc if plldiv = 0 according to pllopt[1] bit, it gives the following pll frequency value f pll : if the pllopt[1] bit is set to 0: f pll = f vco if the pllopt[1] bit is set to 1: f pll = f vco / 2 note that the pllmul field cannot be equal to 0 or 1, or the behavior of the pll will be undefined. plldiv gives also the input frequency of the pll (f in ): if the plldiv field is set to 0: f in = f osc if the plldiv field is greater than 0: f in = f osc / (2 * plldiv) ? pllopt: pll option select the operating range for the pll. pllopt[0]: select the vco frequency range. pllopt[1]: enable the extra output divider. pllopt[2]: disable the wide-bandwidth mode (wide-bandwidth mode allows a faster startup time and out-of-lock time). 31 30 29 28 27 26 25 24 - - pllcount 23 22 21 20 19 18 17 16 ---- pllmul 15 14 13 12 11 10 9 8 ---- plldiv 76543210 - - pllopt pllosc pllen
101 32117b?avr-03/11 at32uc3c ? pllosc: pll os cillator select 0: oscillator 0 is t he source for the pll. 1: oscillator 1 is t he source for the pll. 2: 8mhz/1mhz rcosc is the source for the pll. 3: reserved. ? pllen: pll enable 0: pll is disabled. 1: pll is enabled. note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. table 8-4. pllopt fields description description pllopt[0]: vco frequency 0 160mhz 102 32117b?avr-03/11 at32uc3c 8.6.9 oscillator control register name: oscctrl0,1 access type: read/write offset: 0x0024,0x0028 reset value: 0x00000000 ?oscen 0: disable the oscillator. 1: enable the oscillator. ? startup: oscillator startup time select startup time for the oscillator. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------oscen 15 14 13 12 11 10 9 8 ---- startup 76543210 ----agc gain mode table 8-5. startup time for o scillators 0 and 1 startup number of rc oscillator clock cycle approximative equivalent time (rcsys = 115 khz) 00 0 1 64 560 us 2 128 1.1 ms 3 2048 18 ms 4 4096 36 ms 5 8192 71 ms 6 16384 142 ms 7 32768 285 ms 8 4 35 us 9 8 70 us 10 16 140 us 11 32 280 us 12 256 2.2 ms
103 32117b?avr-03/11 at32uc3c ? agc: automatic gain control 0: disable the automatic gain control of the oscillator. 1: enable the automatic gain control of the oscillator. ? gain: oscillator gain set the gain of the oscillator. ? mode: oscillator mode 0: external clock connected on xin, xout can be used as an i/o (no crystal), disable the oscillator. 1: enable the oscillator. note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. 13 512 4.5 ms 14 1024 9 ms 15 reserved reserved table 8-6. gain value for oscillators 0 and 1 gain crystal frequency 0< 2 mhz 1 between 2 and 10 mhz 2 between 10 and 16 mhz 3> 16 mhz table 8-5. startup time for o scillators 0 and 1 startup number of rc oscillator clock cycle approximative equivalent time (rcsys = 115 khz)
104 32117b?avr-03/11 at32uc3c 8.6.10 1.8v bod control register name: bod access type: read/write offset: 0x002c reset value: 0x00000000 ? sfv: store final value 0: the register is read/write. 1: the register is read-only, to protect against further accidental writes. ? fcd: bod18 fuse calibration done set to 1 when the ctrl, hyst and level fields have been updated by t he flash fuses after a reset. 0: the flash calibration will be redone after any reset. 1: the flash calibration will not be redone after a bod18 reset. ? ctrl: bod18 control ? hyst: bod18 hysteresis 0: no hysteresis. 1: hysteresis on. 31 30 29 28 27 26 25 24 sfv------- 23 22 21 20 19 18 17 16 -------fcd 15 14 13 12 11 10 9 8 ------ ctrl 76543210 - hyst level table 8-7. operation mode for bod18 ctrl description 0x0 bod18 is off 0x1 bod18 is enabled and can reset the chip 0x2 bod18 is enabled, but cannot reset the chip. only interrupt will be sent to interrupt controller, if enabled in the imr register. 0x3 reserved
105 32117b?avr-03/11 at32uc3c ? level: bod18 level this field sets the triggering threshold of the bod18. see electrical characteristics for actual voltage levels. note that any change to the level field of the bod register should be done with the bod18 deactivated to avoid spurious reset or interrupt. note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details.
106 32117b?avr-03/11 at32uc3c 8.6.11 bandgap calibration register name: bgcr access type: read/write offset: 0x0030 reset value: 0x00000000 ? sfv: store final value 0: the register is read/write. 1: the register is read-only, to protect against further accidental writes. ? fcd: flash calibration done set to 1 when the calib field has been updated by the flash fuses after a reset. 0: the flash calibration will be redone after any reset. 1: the flash calibration will not be redone after a bod18 reset. ? calib: calibration value calibration value for bandgap. see electrical characteristics for voltage values. note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. 31 30 29 28 27 26 25 24 sfv------- 23 22 21 20 19 18 17 16 -------fcd 15 14 13 12 11 10 9 8 -------- 7654321 0 ----- calib
107 32117b?avr-03/11 at32uc3c 8.6.12 3.3v bod control register name: bod33 access type: read/write offset: 0x0034 reset value: 0x00000000 ? sfv: store final value 0: the register is read/write. 1: the register is read-only, to protect against further accidental writes. ? fcd: flash calibration done set to 1 when the ctrl field has been updated by the flash fuses after a reset. 0: the flash calibration will be redone after any reset. 1: the flash calibration will not be redone after a bod33 reset. ? ctrl: bod33 control ? hyst: bod33 hysteresis 0: no hysteresis. 1: hysteresis on. 31 30 29 28 27 26 25 24 sfv------- 23 22 21 20 19 18 17 16 -------fcd 15 14 13 12 11 10 9 8 ------ ctrl 76543210 - hyst level table 8-8. operation mode for bod33 ctrl description 0x0 bod33 is off 0x1 bod33 is enabled and can reset the chip 0x2 bod33 is enabled, but cannot reset the chip. only interrupt will be sent to interrupt controller, if enabled in the imr register. 0x3 reserved
108 32117b?avr-03/11 at32uc3c ? level: bod33 level this field sets the triggering threshold of the bod33. see electrical characteristics for actual voltage levels. note that any change to the level field of the bod33 register should be done with the bod33 deactivated to avoid spurious reset or interrupt. note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details.
109 32117b?avr-03/11 at32uc3c 8.6.13 5v bod control register name: bod50 access type: read/write offset: 0x0038 reset value: 0x00000000 ? sfv: store final value 0: the register is read/write. 1: the register is read-only, to protect against further accidental writes. ? ctrl: bod50 control 0: bod50 is off. 1: bod50 is enabled. ? hyst: bod50 hysteresis 0: no hysteresis. 1: hysteresis on. ? level: bod50 level this field sets the triggering threshold of the bod50. see electrical characteristics for actual voltage levels. note that any change to the level field of the bod50 register should be done with the bod50 deactivated to avoid spurious reset or interrupt. note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. 31 30 29 28 27 26 25 24 sfv------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------ctrl 76543210 - hyst level
110 32117b?avr-03/11 at32uc3c 8.6.14 voltage regulator calibration register name: vregcr access type: read/write offset: 0x003c reset value: 0x00000000 ? sfv: store final value 0: the register is read/write. 1: the register is read-only, to protect against further accidental writes. ? fcd: flash calibration done set to 1 when the calib field has been updated by the flash fuses after a reset. 0: the flash calibration will be redone after any reset. 1: the flash calibration will only be redone after a power-on reset. ? calib: calibration value calibration value for voltage reference of the 1.8v voltage regulator. note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. 31 30 29 28 27 26 25 24 sfv------- 23 22 21 20 19 18 17 16 -------fcd 15 14 13 12 11 10 9 8 -------- 76543210 ----- calib
111 32117b?avr-03/11 at32uc3c 8.6.15 voltage regulator control register name: vregctrl access type: read/write offset: 0x0040 reset value: 0x00000000 ? sfv: store final value 0: the register is read/write. 1: the register is read-only, to protect against further accidental writes. ? vreg33ctl: 3.3 voltage regulator control note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. 31 30 29 28 27 26 25 24 sfv------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ---- vreg33ctl - table 8-9. operation mode of 3.3v voltage regulator vreg33ctl description 0x0 3.3v regulator is on 0x1 reserved 0x2 reserved 0x3 3.3v regulator is off
112 32117b?avr-03/11 at32uc3c 8.6.16 rcsys calibration register name: rccr access type: read/write offset: 0x0044 reset value: 0x00000000 ? fcd: flash calibration done set to 1 when calib field has been updated by the flash fuses after a reset. 0: the flash calibration will be redone after any reset. 1: the flash calibration will only be redone after a power-on reset. ? calib: calibration value calibration value for the rc oscillator. note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------fcd 15 14 13 12 11 10 9 8 ------ calib[9:8] 76543210 calib[7:0]
113 32117b?avr-03/11 at32uc3c 8.6.17 8mhz / 1mhz rc oscillator control register name: rccr8 access type: read/write offset: 0x0048 reset value: 0x00000000 ? freqmode: frequency mode 0: the rc8m rc oscillator will run at 8 mhz. 1: the rc8m rc oscillator will run at 1 mhz. ? rcosc8_en: rcosc enable 0: the rc8m rc oscillator is disabled. 1: the rc8m rc oscillator is enabled. ? fcd: flash calibration done set to 1 when calib field has been updated by the flash fuses after a reset. 0: the flash calibration will be redone after any reset. 1: the flash calibration will only be redone after a power-on reset. ? calib: calibration value calibration value for the rc8m rc oscillator. note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. 31 30 29 28 27 26 25 24 ------freqmodercosc8_en 23 22 21 20 19 18 17 16 -------fcd 15 14 13 12 11 10 9 8 -------- 76543210 calib[7:0]
114 32117b?avr-03/11 at32uc3c 8.6.18 32khz oscillator control register name: oscctrl32 access type: read/write offset: 0x004c reset value: 0x00000000 note: this register is only reset by power-on reset. ? startup: oscillator startup time select startup time for 32 khz oscillator. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ----- startup 15 14 13 12 11 10 9 8 ------ mode 76543210 -------osc32en table 8-10. startup time for 32 khz oscillator startup number of rc oscillator clock cycle approximative equivalent time (rcsys = 115 khz) 00 0 1128 1.1ms 2 8192 72.3 ms 3 16384 143 ms 4 65536 570 ms 5 131072 1.1 s 6 262144 2.3 s 7 524288 4.6 s
115 32117b?avr-03/11 at32uc3c ? mode: oscillator mode ? osc32en: enable the 32 khz oscillator 0: 32 khz oscillator is disabled. 1: 32 khz oscillator is enabled. note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. table 8-11. operation mode for 32 khz oscillator mode description 0 external clock connected to xin32, xout32 can be used as i/o (no crystal) 1 2-pin crystal mode. crystal is connected to xin32/xout32 2 2-pin crystal and i-current mode. cr ystal is connected to xin32/xout32 3reserved
116 32117b?avr-03/11 at32uc3c 8.6.19 120mhz rc oscillator control register name: rc120mcr access type: read/write offset: 0x0058 reset value: 0x00000000 ? en: rc120m enable 0: clock is stopped. 1: clock is running. note that this register is protected by a lock. to write to this register the unlock register has to be written first. please refer to the unlock register description for details. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------en
117 32117b?avr-03/11 at32uc3c 8.6.20 general purpose low-power register 0/1 name: gplp0,1 access type: read/write offset: 0x005c,0x0060 reset value: 0x00000000 these registers are general purpose 32-bit registers that are reset only by power-on-reset. any other reset will keep the bits of these registers untouched. note that this registers are protected by a lock. to write to these registers the unlock register has to be written first. please refer to the unlock register description for details. 31 30 29 28 27 26 25 24 data[31:24] 23 22 21 20 19 18 17 16 data[23:16] 15 14 13 12 11 10 9 8 data[15:8] 76543210 data[7:0]
118 32117b?avr-03/11 at32uc3c 8.6.21 generic clock control name: gcctrl access type: read/write offset: 0x0064-0x008c reset value: 0x00000000 there is one gcctrl register per generic clock in the device. ? div: division factor ? oscsel: oscillator select 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 div 15 14 13 12 11 10 9 8 oscsel 76543210 ------divencen table 8-12. generic clock source oscsel clock description 0 rcsys system rc oscillator clock 1 osc32k output clock from osc32k 2 8mhz / 1mhz rcosc output clock from rc8m 3 osc0 out output clock from oscillator 0 4 osc1 out output clock from oscillator 1 5 pll0 out output from pll 0 6 pll1 out output from pll 1 7 cpu clock the clock the cpu runs on 8 hsb clock high speed bus clock 9 pba clock peripheral bus a clock 10 pbb clock peripheral bus b clock 11 pbc clock peripheral bus c clock 12-15 reserved
119 32117b?avr-03/11 at32uc3c ? diven: divide enable 0: the generic clock equals the undivided source clock. 1: the generic clock equals the source clock divided by 2*(div+1). ? cen: clock enable 0: clock is stopped. 1: clock is running.
120 32117b?avr-03/11 at32uc3c 8.6.22 pll interface version register name: pllversion access type: read-only offset: 0x03c8 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
121 32117b?avr-03/11 at32uc3c 8.6.23 oscillator interface version register name: oscversion access type: read-only offset: 0x03cc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
122 32117b?avr-03/11 at32uc3c 8.6.24 1.8v bod interface version register name: bodversion access type: read-only offset: 0x03d0 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
123 32117b?avr-03/11 at32uc3c 8.6.25 3.3v / 5v bod interface version register name: bodbversion access type: read-only offset: 0x03d4 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
124 32117b?avr-03/11 at32uc3c 8.6.26 voltage regulator interface version register name: vregversion access type: read-only offset: 0x03d8 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
125 32117b?avr-03/11 at32uc3c 8.6.27 rcsys interface version register name: rccrversion access type: read-only offset: 0x03dc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
126 32117b?avr-03/11 at32uc3c 8.6.28 8mhz / 1mhz rcosc interface version register name: rccr8version access type: read-only offset: 0x03e0 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
127 32117b?avr-03/11 at32uc3c 8.6.29 32khz oscillator interface version register name: osc32version access type: read-only offset: 0x03e4 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
128 32117b?avr-03/11 at32uc3c 8.6.30 120mhz rc oscillator version register name: rc120mversion access type: read-only offset: 0x03f0 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
129 32117b?avr-03/11 at32uc3c 8.6.31 gplp version register name: gplpversion access type: read-only offset: 0x03f4 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
130 32117b?avr-03/11 at32uc3c 8.6.32 generic clock version register name: gclkversion access type: read-only offset: 0x03f8 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
131 32117b?avr-03/11 at32uc3c 8.6.33 scif version register name: version access type: read-only offset: 0x03fc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:0] 76543210 version[7:0]
132 32117b?avr-03/11 at32uc3c 8.7 module configuration the specific configuration for each scif instanc e is listed in the following tables. the module bus clocks listed here are connected to the syst em bus clocks. please refer to the power man- ager chapter for details. table 8-13. scif clock name module name clock name description scif clk_scif peripheral bus clock from the pba clock domain table 8-14. register reset values register reset value pllversion 0x00000100 oscversion 0x00000101 bodversion 0x00000101 bodbversion 0x00000100 vregversion 0x00000100 rccrversion 0x00000100 rccr8version 0x00000100 osc32version 0x00000100 tsensversion 0x00000100 rc120mifaversion 0x00000100 gplpversion 0x00000110 gclkversion 0x00000100 version 0x00000101
133 32117b?avr-03/11 at32uc3c 9. asynchronous timer (ast) rev: 2.0.0.1 9.1 features ? 32-bit counter with 32-bit prescaler ? clocked source ? system rc oscillator (rcsys) ? 32khz crystal oscillator (osc32k) ?pb clock ? generic clock (gclk) ? 1khz clock from 32khz oscillator ? optional calendar mode supported ? digital prescaler tuning for increased accuracy ? periodic interrup t(s) and peripheral event(s) supported ? alarm interrupt(s) and peripheral event(s) supported ? optional clear on alarm 9.2 overview the asynchronous timer (ast) enables periodi c interrupts and periodic peripheral events, as well as interrupts and peripheral events at a specifi ed time in the future. the ast consists of a 32-bit prescaler which feeds a 32-bit up-counter. the prescaler can be clocked from four differ- ent clock sources, including the low-power 32khz clock, which allows the ast to be used as a real-time timer with a maximum timeout of more than 100 years. also, the pb clock or a generic clock can be used for high-speed operation, a llowing the ast to be used as a general timer. the ast can generate periodic interrupts and peripheral events from output from the prescaler, as well as alarm interrupts and peripheral events, which can trigger at any counter value. addi- tionally, the timer can trigger an overflow interrupt and peripheral event, and be reset on the occurrence of any alarm. this allows periodic interrupts and peripheral events at very long and accurate intervals. the ast has been designed to meet the system tick and real time clock requirements of most embedded operating systems.
134 32117b?avr-03/11 at32uc3c 9.3 block diagram figure 9-1. asynchronous timer block diagram 9.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 9.4.1 power management when the ast is enabled, it will re main clocked as long as its sele cted clock source is running. it can also wake the cpu from the currently active sleep mode. refer to the power manager chap- ter for details on the different sleep modes. 9.4.2 clocks the clock for the ast bus interface (clk_ast) is generated by the power manager. this clock is turned on by default, and can be enabled and disabled in the power manager. a number of clocks can be selected as source for the internal presca ler clock clk_ast_prsc. the prescaler, counter, an d interrupt will function as long as this selected clock source is active. the selected clock must be enabled in the system control interface (scif). the following clock sources are available: ? system rc oscillator (rcsys). th is oscillator is always enabl ed, except in some sleep modes. please refer to the electrical characteri stics chapter for the characteristic frequency of this oscillator. ? 32khz crystal oscillator (osc32k). this oscillator must be enabled before use. 32-bit prescaler rc osc 32-bit counter alarm interrupts counter value ovf 32 khz control register en cssel psel clk_ast_prsc pb clock gclk periodic interrupts alarm register interrupt control irqs periodic interval register events wake control wake wake enable register digital tuner register clk_ast clk_ast clk_ast clk_ast_cnt
135 32117b?avr-03/11 at32uc3c ? peripheral bus clock (pb clock). this is the cl ock of the peripheral bus the ast is connected to. ? generic clock (gclk). one of the generic clocks is connected to the ast. this clock must be enabled before use, and remains enabled in sleep modes when the pb clock is active. 9.4.3 interrupt the ast interrupt request lines are connected to the interrupt controller. using the ast inter- rupts requires the interrupt controller to be programmed first. 9.4.4 peripheral events the ast peripheral events are connected via the peripheral event system. refer to the periph- eral event system chapter for details. 9.4.5 debug operation the ast prescaler and counter is frozen during debug operation, unless the run in debug bit in the development control register is set and the bit corresponding to the ast is set in the peripheral debug register (pdbg). please refer to the on-chip debug chapter in the avr32uc technical reference manual, and the ocd module configuration section, for details. if the ast is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. 9.5 functional description 9.5.1 initialization before enabling the ast, the internal ast clock clk_ast_prsc mu st be enabled, following the procedure specified in section 9.5.1.1 . the clock source select field in the clock register (clock.cssel) selects the source for this clock. the clock en able bit in the clock register (clock.cen) enables the clk_ast_prsc. when clk_ast_prsc is enabled, the ast can be enabled by writing a one to the enable bit in the control register (cr.en). 9.5.1.1 enabling and disabling the ast clock the clock source selection field (clock.cssel ) and the clock enable bit (clock.cen) can- not be changed simultaneously. special procedures must be followed for enabling and disabling the clk_ast_prsc and for changing the source for this clock. to enable clk_ast_prsc: ? write the selected value to clock.cssel ? wait until sr.clkbusy reads as zero ? write a one to clock.cen, without changi ng clock.cssel ? wait until sr.clkbusy reads as zero to disable the clock: ? write a zero to clock.cen to disable the clock, without changing clock.cssel ? wait until sr.clkbusy reads as zero
136 32117b?avr-03/11 at32uc3c 9.5.1.2 changing the source clock the clk_ast_prsc must be disabled before swit ching to another source clock. the clock busy bit in the status register (sr.clkbusy) indicates whether the clock is busy or not. this bit is set when the cen bit in the clock register is changed, and cleared when the clock reg- ister can be changed. to change the clock: ? write a zero to clock.cen to disable the clock, without changing clock.cssel ? wait until sr.clkbusy reads as zero ? write the selected value to clock.cssel ? wait until sr.clkbusy reads as zero ? write a one to clock.cen to enable the clock, without ch anging clock.cssel ? wait until sr.clkbusy reads as zero 9.5.2 basic operation 9.5.2.1 prescaler when the ast is enabled, the 32-bit pr escaler will increment on the rising edge of clk_ast_prsc. the prescaler value cannot be read or written, but it can be reset by writing a one to the prescaler clear bit in the control register (cr.pclr). the prescaler select field in the control regist er (cr.psel) selects the prescaler bit psel as source clock for the counter (clk_ast_cnt). this results in a counter frequency of: where f prsc is the frequency of the internal prescaler clock clk_ast_prsc. 9.5.2.2 counter operation when enabled, the ast will increment on every 0-to-1 transition of the selected prescaler tapping. when the calender bit in the control r egister (cr.cal) is zero, the counter oper- ates in counter mode. it will increment until it reaches the top value of 0xffffffff, and then wrap to 0x00000000. this sets the status bit overflow in the status register (sr.ovf). optionally, the counter can also be reset when a timer alarm occurs (see section 9.5.3.2 ), which will also set the ovf bit. the ast counter value can be read from or written to the counter value (cv) register. note that due to synchronization, continuous reading of the cv register with the lowest prescaler setting will skip every third value. in addition, if clk_ast_prsc is as fast as, or faster than, the clk_ast, the prescaler value must be 3 or higher to be able to read the cv without skipping values. f cnt f prsc 2 psel 1 + ---------------------- - =
137 32117b?avr-03/11 at32uc3c 9.5.2.3 calendar operation when the cal bit in the control register is one, the counter operates in calendar mode. before this mode is enabled, the prescaler should be set up to give a pulse every second. the date and time can then be read from or written to the calendar value (calv) register. time is reported as seconds, minutes, and hours according to the 24-hour clock format. date is the numeral date of month (starting on 1). month is the numeral month of the year (1 = january, 2 = february, etc). year is a 6-bit field counting the offset from a software-defined leap year (e.g. 2000). the date is automatically compensated for leap years, assuming every year divisible by 4 is a leap year. all peripheral events and interrupts work the same way in calendar mode as in counter mode. however, the alarm register (ar) must be written in time/date format for the alarm to trigger correctly. 9.5.3 interrupts the ast can generate five separate interrupt requests: ?ovf: ovf ? per: per0 , per1 ?alarm: alarm0 , alarm1 ? clkready ? ready this allows the user to allocate separate handlers and priorities to the different interrupt types. the generation of the per interrupt is described in section 9.5.3.1 ., and the generation of the alarm interrupt is described in section 9.5.3.2 . the ovf interrupt is generated when the coun- ter overflows, or when the alarm value is reac hed, if the clear on alarm bit in the control register is one. the clkready interrupt is generated when sr.clkbusy has a 1-to-0 transi- tion, and indicates that the clock synchroniz ation is completed. the ready interrupt is generated when sr.busy has a 1-to-0 transition, and indicates that the synchronization described in section 9.5.7 is completed. an interrupt request will be generated if the corresponding bit in the interrupt mask register (imr) is set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier), and cleared by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt request remains acti ve until the corresponding bit in sr is cleared by writing a one to the corresponding bit in the status clear register (scr). the ast interrupts can wake the cpu from any sleep mode where the source clock and the interrupt controller is active. 9.5.3.1 periodic interrupt the ast can generate periodic interrupts. if the pern bit in the interrupt mask register (imr) is one, the ast will generate an interrup t request on the 0-to-1 transition of the selected bit in the
138 32117b?avr-03/11 at32uc3c prescaler when the ast is enabled. the bit is selected by the interval select field in the corre- sponding periodic interval register (pirn.insel), resulting in a periodic interrupt frequency of where f cs is the frequency of the selected clock source. the corresponding pern bit in the status register (sr) will be set when the select ed bit in the prescaler has a 0-to-1 transition. because of synchronizat ion, the transfer of the insel va lue will not happen immediately. when changing/setting the insel value, the user must make sure that the prescaler bit number insel will not have a 0-to-1 transition be fore the insel value is transferr ed to the register. in that case, the first periodic interrupt afte r the change will no t be triggered. 9.5.3.2 alarm interrupt the ast can also generate alar m interrupts. if the al armn bit in imr is one, the ast will gen- erate an interrupt request when the counter val ue matches the selected alarm value, when the ast is enabled. the alarm value is selected by writing the value to the value field in the corre- sponding alarm register (arn.value). the corresponding alarmn bit in sr will be set when the counter reaches the selected alarm value. because of synchronization, the transfer of t he alarm value will not happen immediately. when changing/setting the alarm value, the user must make sure that the counter will not count the selected alarm value before the value is transferred to the register. in that case, the first alarm interrupt after the cha nge will not be triggered. if the clear on alarm bit in the control register (cr.can) is one, the corresponding alarm inter- rupt will clear the count er and set the ovf bit in the stat us register. this will generate an overflow interrupt if the ovf bit in imr is set. 9.5.4 peripheral events the ast can generate a number of peripheral events: ?ovf ? per0 ? per1 ?alarm0 ?alarm1 the pern peripheral event(s) is generated the same way as the per interrupt, as described in section 9.5.3.1 . the alarmn peripheral event(s) is generated the same way as the alarm interrupt, as described in section 9.5.3.2 . the ovf peripheral event is generated the same way as the ovf interrupt, as described in section 9.5.3 - f pa f cs 2 insel 1 + ------------------------- =
139 32117b?avr-03/11 at32uc3c the peripheral event will be genera ted if the corresponding bit in the event mask (evm) register is set. bits in evm register are set by writing a one to the corresponding bit in the event enable (eve) register, and cleared by writing a one to the corresponding bit in the event disable (evd) register. 9.5.5 ast wakeup the ast can wake up the cpu directly, without the need to trigger an interrupt. a wakeup can be generated when the counter overflows, when the counter reaches the selected alarm value, or when the selected prescaler bit has a 0-to-1 transition. in this case, the cpu will continue executing from the instruction following the sleep instruction. the ast wakeup is enabled by writing a one to th e corresponding bit in the wake enable regis- ter (wer). when the cpu wakes from sleep, the wake signal must be cleared by writing a one to the corresponding bit in scr to clear the internal wake signal to the sleep controller. if the wake signal is not cleared after waking from sl eep, the next sleep instru ction will have not effect because the cpu will wake immediatel y after this sl eep instruction. the ast wakeup can wake the cpu from any sleep mode where the source clock is active. the ast wakeup can be configured independently of the interrupt masking. 9.5.6 digital tuner the digital tuner adds the possibility to compensate for a too slow or a too fast input clock. the add bit in the digital tuner re gister (dtr.add) selects if the tuned frequency should be reduced or increased. if add is ?0?, the prescaler frequency is reduced: where f tuned is the tuned frequency, is the original prescaler frequency, and value and exp are the correspo nding fields to be pr ogrammed in dt r. note that dtr.exp must be greater than zero. frequency tuning is disabled by programming dtr.value as zero. if add is ?1?, the prescaler frequency is increased: note that these formulas to be within an error of 0.01%, it is recommended that the prescaler bit that is used as the clo ck for the counter (selecte d by cr.psel) or to trigge r the periodic interrupt (selected by pirn.insel) be bit 6 or higher. f tuned f 0 1 1 roundup 256 value ------------------- - ?? ?? 2 exp () ? 1 + -------------------------------------------------------------------------------- ? ?? ?? ?? ?? ?? = f 0 f tuned f 0 1 1 roundup 256 value ------------------- - ?? ?? 2 exp () ? 1 ? -------------------------------------------------------------------------------- + ?? ?? ?? ?? ?? =
140 32117b?avr-03/11 at32uc3c 9.5.7 synchronization as the prescaler and counter operate asynchronously from the user interface, the ast needs a few clock cycles to synchronize values written to the cr, cv, scr, wer, eve, evd, pirx, arx and dtr registers. the busy bit in the status register (sr.busy) indicates that the synchroni- zation is ongoing. during this time, wr ites to these registers will be discarded. note that synchronization takes place also if the prescaler is clocked from clk_ast.
141 32117b?avr-03/11 at32uc3c 9.6 user interface note: 1. the reset values are device specific. please refer to the module configuration section at the end of this chapter. 2. the number of alarm and periodic interval registers are device specific. please refer to the module configuration section at the end of this chapter. table 9-1. ast register memory map offset register register name access reset 0x00 control register cr read/write 0x00000000 0x04 counter value cv read/write 0x00000000 0x08 status register sr read-only 0x00000000 0x0c status clear register scr write-only 0x00000000 0x10 interrupt enable register ier write-only 0x00000000 0x14 interrupt disable register idr write-only 0x00000000 0x18 interrupt mask register imr read-only 0x00000000 0x1c wake enable register wer read/write 0x00000000 0x20 alarm register 0 (2) ar0 read/write 0x00000000 0x24 alarm register 1 (2) ar1 read/write 0x00000000 0x30 periodic interval register 0 (2) pir0 read/write 0x00000000 0x34 periodic interval register 1 (2) pir1 read/write 0x00000000 0x40 clock control register clock read/write 0x00000000 0x44 digital tuner register dtr read/write 0x00000000 0x48 event enable eve write-only 0x00000000 0x4c event disable evd write-only 0x00000000 0x50 event mask evm read-only 0x00000000 0x54 calendar value calv read/write 0x00000000 0xf0 parameter register parameter read-only - (1) 0xfc version register version read-only - (1)
142 32117b?avr-03/11 at32uc3c 9.6.1 control register name: cr access type: read/write offset :0x00 reset value: 0x00000000 when the sr.busy bit is set, writes to this register will be discarded and this re gister will read as zero. ? psel: prescaler select selects prescaler bit psel as source clock for the counter. ? can: clear on alarm n 0: the corresponding alarm will not clear the counter. 1: the corresponding alarm will clear the counter. ? cal: calendar mode 0: the ast operates in counter mode. 1: the ast operates in calendar mode. ? pclr: prescaler clear writing a zero to this bit has no effect. writing a one to this bit clears the prescaler. this bit always reads as zero. ? en: enable 0: the ast is disabled. 1: the ast is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 --- psel 15 14 13 12 11 10 9 8 ------ca1ca0 76543210 - - - - cal pclr en
143 32117b?avr-03/11 at32uc3c 9.6.2 counter value name: cv access type: read/write offset :0x04 reset value: 0x00000000 when the sr.busy bit is set, writes to this register will be discarded and this re gister will read as zero. ? value: ast value ? the current value of the ast counter. 31 30 29 28 27 26 25 24 value[31:24] 23 22 21 20 19 18 17 16 value[23:16] 15 14 13 12 11 10 9 8 value[15:8] 76543210 value[7:0]
144 32117b?avr-03/11 at32uc3c 9.6.3 status register name: sr access type: read-only offset :0x08 reset value: 0x00000000 ? clkready: clock ready this bit is cleared when the corresponding bit in scr is written to one. this bit is set when the sr.clkbusy bit has a 1-to-0 transition. ? clkbusy: clock busy ? 0: the clock is ready and can be changed. ? 1: clock.cen has been written and the clock is busy. ? ready: ast ready this bit is cleared when the corresponding bit in scr is written to one. this bit is set when the sr.busy bit has a 1-to-0 transition. ? busy: ast busy 0: the ast accepts writes to cr, cv, s cr, wer, eve, evd, arn, and pirn, and dtr. 1: the ast is busy and will discard writes to cr, cv, scr, wer, eve, evd, arn, and pirn, and dtr. ? pern: periodic n this bit is cleared when the corresponding bit in scr is written to one. this bit is set when the selected bit in the prescaler has a 0-to-1 transition. ? alarmn: alarm n this bit is cleared when the corresponding bit in scr is written to one. this bit is set when the counter reaches the selected alarm value. ? ovf: overflow this bit is cleared when the corresponding bit in scr is written to one. this bit is set when an overflow has occurred. 31 30 29 28 27 26 25 24 - - clkready clkbusy - - ready busy 23 22 21 20 19 18 17 16 ------per1per0 15 14 13 12 11 10 9 8 - - - - - - alarm1 alarm0 76543210 -------ovf
145 32117b?avr-03/11 at32uc3c 9.6.4 status clear register name: scr access type: write-only offset :0x0c reset value: 0x00000000 when the sr.busy bit is set, writes to this register will be discarded. writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in sr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 - - clkready - - - ready - 23 22 21 20 19 18 17 16 ------per1per0 15 14 13 12 11 10 9 8 - - - - - - alarm1 alarm0 76543210 -------ovf
146 32117b?avr-03/11 at32uc3c 9.6.5 interrupt enable register name: ier access type: write-only offset :0x10 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 - - clkready - - - ready - 23 22 21 20 19 18 17 16 ------per1per0 15 14 13 12 11 10 9 8 - - - - - - alarm1 alarm0 76543210 -------ovf
147 32117b?avr-03/11 at32uc3c 9.6.6 interrupt disable register name: idr access type: write-only offset :0x14 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 - - clkready - - - ready - 23 22 21 20 19 18 17 16 ------per1per0 15 14 13 12 11 10 9 8 - - - - - - alarm1 alarm0 76543210 -------ovf
148 32117b?avr-03/11 at32uc3c 9.6.7 interrupt mask register name: imr access type: read-only offset :0x18 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 - - clkready - - - ready - 23 22 21 20 19 18 17 16 ------per1per0 15 14 13 12 11 10 9 8 - - - - - - alarm1 alarm0 76543210 -------ovf
149 32117b?avr-03/11 at32uc3c 9.6.8 wake enable register name: wer access type: read/write offset :0x1c reset value: 0x00000000 when the sr.busy bit is set writes to this register will be discarded and this register will read as zero. this register enables the wakeup signal from the ast. ? pern: periodic n 0: the cpu will not wake up from sleep mode when the se lected bit in the prescaler has a 0-to-1 transition. 1: the cpu will wake up from sleep mode when the sele cted bit in the prescaler has a 0-to-1 transition. ? alarmn: alarm n 0: the cpu will not wake up from sleep mode when the counter reaches the selected alarm value. 1: the cpu will wake up from sleep mode when the counter reaches the selected alarm value. ? ovf: overflow 0: a counter overflow will not wake up the cpu from sleep mode. 1: a counter overflow will wake up the cpu from sleep mode. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------per1per0 15 14 13 12 11 10 9 8 - - - - - - alarm1 alarm0 76543210 -------ovf
150 32117b?avr-03/11 at32uc3c 9.6.9 alarm register name: ar0/1 access type: read/write offset : 0x20/0x24 reset value: 0x00000000 when the sr.busy bit is set writes to this regist er will be discarded and this register will read as zero. ? value: alarm value ? when the counter reaches this value, an alarm is generated. 31 30 29 28 27 26 25 24 value[31:24] 23 22 21 20 19 18 17 16 value[23:16] 15 14 13 12 11 10 9 8 value[15:8] 76543210 value[7:0]
151 32117b?avr-03/11 at32uc3c 9.6.10 periodic interval register name: pir0/1 access type: read/write offset : 0x30/0x34 reset value: 0x00000000 when the sr.busy bit is set writes to this regist er will be discarded and this register will read as zero. ? insel: interval select ? the pern bit in sr will be set when the insel bit in the prescaler has a 0-to-1 transition. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --- insel
152 32117b?avr-03/11 at32uc3c 9.6.11 clock control register name: clock access type: read/write offset :0x40 reset value: 0x00000000 when writing to this register, follow the sequence in section 9.5.1 . ? cssel: clock source selection this field defines the clock source clk_ast_prsc for the prescaler: ? cen: clock enable 0: clk_ast_prsc is disabled. 1: clk_ast_prsc is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----- cssel 76543210 -------cen table 9-2. clock source selection cssel clock source 0 system rc oscillator (rcsys) 1 32khz oscillator (osc32k) 2 pb clock 3 generic clock (gclk)
153 32117b?avr-03/11 at32uc3c 9.6.12 digital tuner register name: dtr access type: read/write offset :0x44 reset value: 0x00000000 when the sr.busy bit is set writes to this regist er will be discarded and this register will read as zero. ? value: 0: the frequency is unchanged. 1-255: the frequency will be adjusted according to the formula below. ? add: 0: the resulting frequency is for . 1: the resulting frequency is for . ? exp: the frequency will be adjusted according to the formula above. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 va l u e 76543210 - - add exp f 01 1 roundup 256 value ------------------- - ?? ?? 2 exp () ? 1 + ------------------------------------------------------------------------------- ? ?? ?? ?? ?? ?? = value 0 > f 01 1 roundup 256 value ------------------- - ?? ?? 2 exp () ? 1 ? ------------------------------------------------------------------------------- + ?? ?? ?? ?? ?? = value 0 >
154 32117b?avr-03/11 at32uc3c 9.6.13 event enable register name: eve access type: write-only offset :0x48 reset value: 0x00000000 when the sr.busy bit is set writes to this register will be discarded and this register will read as zero. writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in evm. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------per1per0 15 14 13 12 11 10 9 8 - - - - - - alarm1 alarm0 76543210 -------ovf
155 32117b?avr-03/11 at32uc3c 9.6.14 event disable register name: evd access type: write-only offset :0x4c reset value: 0x00000000 when the sr.busy bit is set writes to this register will be discarded and this register will read as zero. writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in evm. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------per1per0 15 14 13 12 11 10 9 8 - - - - - - alarm1 alarm0 76543210 -------ovf
156 32117b?avr-03/11 at32uc3c 9.6.15 event mask register name: evm access type: read-only offset :0x50 reset value: 0x00000000 0: the corresponding peripheral event is disabled. 1: the corresponding peripheral event is enabled. this bit is cleared when the corresponding bit in evd is written to one. this bit is set when the corresponding bit in eve is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------per1per0 15 14 13 12 11 10 9 8 - - - - - - alarm1 alarm0 76543210 -------ovf
157 32117b?avr-03/11 at32uc3c 9.6.16 calendar value name: calv access type: read/write offset :0x54 reset value: 0x00000000 when the sr.busy bit is set writes to this regist er will be discarded and this register will read as zero. ? year: year ? current year. the year is considered a leap year if year[1:0] = 0. ? month: month ?1 = january ? 2 = february ?... ? 12 = december ? day: day ? day of month, starting with 1. ? hour: hour ? hour of day, in 24-hour clock format. ? legal values are 0 through 23. ? min: minute ? minutes, 0 through 59. ? sec: second ? seconds, 0 through 59. 31 30 29 28 27 26 25 24 year month[3:2] 23 22 21 20 19 18 17 16 month[1:0] day hour[4] 15 14 13 12 11 10 9 8 hour[3:0] min[5:2] 76543210 min[1:0] sec
158 32117b?avr-03/11 at32uc3c 9.6.17 parameter register name: parameter access type: read-only offset :0xf0 reset value: - this register gives the configuration used in the specific device. also refe r to the module configuration section. ? dt: digital tuner ? 0: digital tuner off ? 1: digital tuner on ? dtrexpwa: digital tuner exponent writeable ? 0: digital tuner exponent is a constant value. writes to exp bitfield in dtr will be discarded. ? 1: digital tuner exponent is chosen by writing to exp bitfield in dtr ? dtrexpvalue: digital tuner exponent value ? digital tuner exponent value if dt_exp_wa is zero ? numar: number of alarm comparators 0: zero alarm comparators. 1: one alarm comparator. 2: two alarm comparators. ? numpir: number of periodic comparators 0: one periodic comparator. 1: two periodic comparator. ? pirnwa: periodic interval n writeable 0: periodic interval n prescaler tapping is a constant value. writes to insel field in pirn register will be discarded. 1: periodic interval n prescaler tapping is chos en by writing to insel field in pirn register. ? pernvalue: periodic interval n value periodic interval prescaler n tapping if pirnwa is zero. 31 30 29 28 27 26 25 24 - - - per1value 23 22 21 20 19 18 17 16 - - - per0value 15 14 13 12 11 10 9 8 pir1wa pir0wa - numpir numar 76543210 - dtexpvalue dtexpwa dt
159 32117b?avr-03/11 at32uc3c 9.6.18 version register name: version access type: read-only offset :0xfc reset value: 0x00000300 ? variant: variant number ? reserved. no functionality associated. ? version: version number ? version of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
160 32117b?avr-03/11 at32uc3c 9.7 module configuration the specific configuration for each ast instance is listed in the following tables. the module bus clocks listed here are connected to the system bus clocks according to the table in the system bus clock connections section. table 9-3. module configuration feature ast number of timer alarms 2 number of periodic alarms 2 digital tuner on table 9-4. module clock name module name clock name description ast clk_ast peripheral bus clock from the pba clock domain gclk the generic clock used for the ast is gclk2 pb clock peripheral bus clock from the pba clock domain table 9-5. register reset values module name clock name version 0x00000200 parameter 0x0000d203
161 32117b?avr-03/11 at32uc3c 10. watchdog timer (wdt) rev: 4.1.0.0 10.1 features ? watchdog timer counter with 32-bit counter ? timing window watchdog ? clocked from system rc oscillator or the 32 khz crystal oscillator ? configuration lock ? wdt may be enabled at reset by a fuse 10.2 overview the watchdog timer (wdt) will reset the device unless it is periodically serviced by the soft- ware. this allows the device to recover from a condition that has caused the system to be unstable. the wdt has an internal counter clocked from th e system rc oscillator or the 32 khz crystal oscillator. the wdt counter must be periodically cleared by software to avoid a watchdog reset. if the wdt timer is not cleared correctly, the device will reset and start executing from the boot vector. 10.3 block diagram figure 10-1. wdt block diagram 10.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. clk_cnt watchdog detector 32-bit counter watchdog reset 0 1 rcsys osc32k cssel cen sync clk_cnt domain pb clock domain pb wdtclr window, cleared en, mode, psel, tban ctrl clr sr
162 32117b?avr-03/11 at32uc3c 10.4.1 power management when the wdt is enabled, the wdt remains clocked in all sleep modes. it is not possible to enter sleep modes where the source clock of clk_cnt is stopped. atte mpting to do so will result in the chip entering the lowest sleep mode where the source clock is running, leaving the wdt operational. please refer to the power manager chapter for details about sleep modes. after a watchdog reset the wdt bit in the reset cause register (rcause) in the power man- ager will be set. 10.4.2 clocks the clock for the wdt bus interface (clk_wdt) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to dis- able the wdt before disabling the clock, to avoid freezing the wdt in an undefined state. there are two possible clock sources for the watchdog timer (clk_cnt): ? system rc oscillator (rcsys): th is oscillator is always enabl ed when selected as clock source for the wdt. please re fer to the power manager chapter for details about the rcsys and sleep modes. please refer to the electrical characteristics chapter for the characteristic frequency of this oscillator. ? 32 khz crystal oscillator (osc32k) : this oscillator has to be en abled in the system control interface before using it as cloc k source for the wdt. the wdt will not be able to detect if this clock is stopped. 10.4.3 debug operation the wdt counter is frozen during debug operation, unless the run in debug bit in the develop- ment control register is set and the bit corresponding to the wdt is set in the peripheral debug register (pdbg). please refer to the on-chip debug chapter in the avr32uc technical refer- ence manual, and the ocd module configuration section, for details. if the wdt counter is not frozen during debug operation it will need periodically clearing to avoid a watchdog reset. 10.4.4 fuses the wdt can be enabled at reset. this is controlled by the wdtauto fuse, see section 10.5.4 for details. please refer to the fuse settings se ction in the flash controller chapter for details about wdtauto and how to program the fuses. 10.5 functional description 10.5.1 basic mode 10.5.1.1 wdt control register access to avoid accidental disabling of the watchdog, the control register (ctrl) must be written twice, first with the key field set to 0x55, t hen 0xaa without changing the other bits. failure to do so will cause the write operat ion to be ignored, an d the value in the ctrl register will not be changed. 10.5.1.2 changing clk_cnt clock source after any reset, except for watchdog reset, clk_cnt will be enabled with the rcsys as source.
163 32117b?avr-03/11 at32uc3c to change the clock for the wdt the following steps need to be taken. note that the wdt should always be disabled before changing the clk_cnt source: 1. write a zero to the clock enable (cen) bit in the ctrl register, leaving the other bits as they are in the ctrl register. this will stop clk_cnt. 2. read back the ctrl register until the cen bit reads zero. the clock has now been stopped. 3. modify the clock source select (cssel) bit in the ctrl register wit h your new clock selec- tion and write it to the ctrl register. 4. write a one to the cen bit, leaving the other bits as they are in the ctrl register. this will enable the clock. 5. read back the ctrl register until the cen bit reads one. the clock has now been enabled. 10.5.1.3 configuring the wdt if the mode bit in the ctrl register is zero, the wdt is in basic mode. the time out prescale select (psel) field in the ctrl regi ster selects the wdt timeout period: t timeout = t psel = 2 (psel+1) / f clk_cnt 10.5.1.4 enabling the wdt to enable the wdt write a one to the enable (en) bit in the ctrl register. due to internal syn- chronization, it will take some time for the ctrl.en bit to read back as one. 10.5.1.5 clearing the wdt counter the wdt counter is cleared by writing a one to the watchdog clear (wdtclr) bit in the clear (clr) register, at any correct write to the ctrl register, or when the counter reaches t timeout and the chip is reset. in basic mode the clr.wd tclr can be written at any time when the wdt counter cleared (cleared) bit in the status register (sr) is one. due to internal synchroniza- tion, clearing the wdt counter takes some time . the sr.cleared bit is cleared when writing to clr.wdtclr bit and set when the clearing is done. any write to the clr.wdtclr bit while sr.cleared is zero will not clear th e counter. writing to the clr.wdtclr bit has to be done in a particular sequence to be valid. the clr register must be written twice, first with the key field set to 0x 55 and wdtclr set to one, then a second write with the key set to 0xaa without changing the wdtclr bit. writing to the clr register without the correct sequence has no effect. if the wdt counter is periodically cleared within t psel no watchdog rese t will be issued, see fig- ure 10-2 on page 164 .
164 32117b?avr-03/11 at32uc3c figure 10-2. basic mode wdt timing diagram, normal operation. if the wdt counter is not cleared within t psel a watchdog reset will be issued at the end of t psel , see figure 10-3 on page 164 . figure 10-3. basic mode wdt timing diagram, no clear within t psel . 10.5.1.6 watchdog reset a watchdog reset will result in a reset and the code will start executing from the boot vector, please refer to the power manager chapter for details. if the disable after reset (dar) bit in the ctrl register is zero, the wdt counter will restart counting from zero when the watchdog reset is released. if the ctrl.dar bit is one the wdt will be di sabled after a watchdog re set. only the ctrl.en bit will be changed after the watc hdog reset. however, if wdtauto fuse is configured to enable the wdt after a watchdog reset, and the ctrl.fcd bit is zero, writing a one to the ctrl.dar bit will have no effect. 10.5.2 window mode the window mode can protect against tight loops of runaway code. this is obtained by adding a ban period to timeout period. during the ban period clearing the wdt counter is not allowed. if the wdt mode (mode) bit in the ctrl register is one, the wdt is in window mode. note that the ctrl.mode bit can only be change d when the wdt is di sabled (ctrl.en=0). t psel timeout write one to clr.wdtclr watchdog reset t=t 0 t psel timeout write one to clr.wdtclr watchdog reset t=t 0
165 32117b?avr-03/11 at32uc3c the psel and time ban prescale select (tban) fields in the ctrl register selects the wdt timeout period t timeout = t tban + t psel = (2 (tban+1) + 2 (psel+1) ) / f clk_cnt where t tban sets the time period when clearing the wdt counter by writing to the clr.wdtclr bit is not allowed. doing so will result in a watc hdog reset, the device w ill receive a reset and the code will start executing form the boot vector, see figure 10-5 on page 165 . the wdt counter will be cleared. writing a one to the clr.wdtclr bit within the t psel period will clear the wdt counter and the counter starts counting from zero (t=t 0 ), entering t tban , see figure 10-4 on page 165 . if the value in the ctrl register is changed , the wdt counter will be cleared without a watch- dog reset, regardless of if the value in the wdt counter and the tban value. if the wdt counter reaches t timeout , the counter will be cleared, the device will receive a reset and the code will start execut ing form the boot vector. figure 10-4. window mode wdt timing diagram figure 10-5. window mode wdt timing diagram, clearing within t tban , resulting in watchdog reset. t tban t psel timeout write one to clr.wdtclr watchdog reset t=t 0 t tban t psel timeout w rite one to clr.wdtclr w atchdog reset t=t 0
166 32117b?avr-03/11 at32uc3c 10.5.3 disabling the wdt the wdt is disabled by writing a zero to the ctrl.en bit. when disabling the wdt no other bits in the ctrl register should be changed until the ctrl.en bit reads back as zero. if the ctrl.cen bit is written to zero, the ctrl.en bit will never read back as zero if changing the value from one to zero. 10.5.4 flash calibration the wdt can be enabled at rese t. this is controlled by the wdtauto fuse. the wdt will be set in basic mode, rcsys is set as source fo r clk_cnt, and psel will be set to a value giving t psel above 100 ms. please refer to the fuse settings chapter for details about wdtauto and how to program the fuses. if the flash calibration done (fcd) bit in the ctrl register is zero at a watchdog reset the flash calibration will be redone, and the ctrl.fcd bi t will be set when the calibration is done. if ctrl.fcd is one at a watchdog reset, the conf iguration of the wdt will not be changed during flash calibration. after any other reset the fl ash calibration will always be done, and the ctrl.fcd bit will be set when the calibration is done. 10.5.5 special considerations care must be taken when selecting the psel/tban va lues so that the time out period is greater than the startup time of the ch ip. otherwise a watchdog reset will reset the chip before any code has been run. this can also be avoided by writ ing the ctrl.dar bit to one when configuring the wdt. if the store final value (sfv) bit in the ctrl register is one, the ctrl register is locked for further write accesses. all writes to the ctrl register will be i gnored. once the ctrl register is locked, it can only be unlocked by a reset (e.g. por, ocd, and wdt). the ctrl.mode bit can only be changed when the wdt is disabled (ctrl.en=0).
167 32117b?avr-03/11 at32uc3c 10.6 user interface note: 1. the reset value for this register is device specific. plea se refer to the module configur ation section at the end of thi s chapter. table 10-1. wdt register memory map offset register register name access reset 0x000 control register ctrl read/write 0x00010080 0x004 clear register clr write-only 0x00000000 0x008 status register sr read-only 0x00000003 0x3fc version register version read-only - (1)
168 32117b?avr-03/11 at32uc3c 10.6.1 control register name: ctrl access type: read/write offset: 0x000 reset value: 0x00010080 ?key this field must be written twice, first with key value 0x55, t hen 0xaa, for a write operation to be effective. this field alway s reads as zero. ? tban: time ban prescale select counter bit tban is used as watchdog ?banned? time frame. in this time frame clearing the wdt timer is forbidden, otherwise a watchdog reset is generated and the wdt timer is cleared. ? cssel: clock source select 0: select the system rc oscillator (rcsys) as clock source. 1: select the 32khz crystal osc illator (osc32k) as clock source. ? cen: clock enable 0: the wdt clock is disabled. 1: the wdt clock is enabled. ? psel: time out prescale select counter bit psel is used as watchdog timeout period. ? fcd: flash calibration done this bit is set after any reset. 0: the flash calibration will be redone after a watchdog reset. 1: the flash calibration will not be redone after a watchdog reset. ? sfv: wdt control register store final value 0: wdt control register is not locked. 1: wdt control register is locked. once locked, the control register can not be re-written, only a reset unlocks the sfv bit. ?mode: wdt mode 0: the wdt is in basic mode, only psel time is used. 1: the wdt is in window mode. tota l timeout period is now tban+psel. writing to this bit when the wdt is enabled has no effect. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 - tban cssel cen 15 14 13 12 11 10 9 8 - - - psel 76543210 fcd - - - sfv mode dar en
169 32117b?avr-03/11 at32uc3c ? dar: wdt disable after reset 0: after a watchdog reset, the wdt will still be enabled. 1: after a watchdog reset, the wdt will be disabled. ? en: wdt enable 0: wdt is disabled. 1: wdt is enabled. after writing to this bit the read back value will not change until the wdt is enabled/disabled. this due to internal synchronization.
170 32117b?avr-03/11 at32uc3c 10.6.2 clear register name: clr access type: write-only offset: 0x004 reset value: 0x00000000 when the watchdog timer is enabled, this register must be periodically written within the window time frame or within the watchdog timeout period, to prevent a watchdog reset. ?key this field must be written twice, first with key value 0x55, then 0xaa, for a write operation to be effective. ? wdtclr: watchdog clear writing a zero to this bit has no effect. writing a one to this bit clears the wdt counter. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------wdtclr
171 32117b?avr-03/11 at32uc3c 10.6.3 status register name: sr access type: read-only offset: 0x008 reset value: 0x00000003 ? cleared: wdt counter cleared this bit is cleared when writing a one to the clr.wdtclr bit. this bit is set when clearing the wdt counter is done. ? window: within window this bit is cleared when the wdt counter is inside the tban period. this bit is set when the wdt counter is inside the psel period. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------clearedwindow
172 32117b?avr-03/11 at32uc3c 10.6.4 version register name: version access type: read-only offset: 0x3fc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
173 32117b?avr-03/11 at32uc3c 10.7 module configuration the specific configuration for each wdt instance is listed in the following tables. the module bus clocks listed here are connected to the syst em bus clocks. please refer to the power man- ager chapter for details. table 10-2. module clock name module name clock name description wdt clk_wdt peripheral bus clock from the pba clock domain table 10-3. register reset values register reset value version 0x00000410
174 32117b?avr-03/11 at32uc3c 11. interrupt controller (intc) rev: 1.0.2.5 11.1 features ? autovectored low latency interrupt service with programmable priority ? 4 priority levels for regular, maskable interrupts ? one non-maskable interrupt ? up to 64 groups of interrupts with up to 32 interrupt requests in each group 11.2 overview the intc collects interrupt requests from the peripherals, prioritizes them, and delivers an inter- rupt request and an autovector to the cpu. the avr32 architecture supports 4 priority levels for regular, maskable interrupts, and a non-maskable interrupt (nmi). the intc supports up to 64 groups of interrupts. each group can have up to 32 interrupt request lines, these lines are connected to the peripherals. each group has an interrupt priority register (ipr) and an interrupt request register (irr). the iprs are used to assign a priority level and an autovector to each group, and the irrs are used to identify the active interrupt request within each group. if a group has only one interrupt request line, an active interrupt group uniquely identifies the active interrupt request line, and the corresponding irr is not needed. the intc also provides one interrupt cause register (icr) per priority level. these registers identify the group that has a pending interrupt of the corresponding priority level. if several groups have a pending interrupt of the same level, the group with the lowest number takes priority. 11.3 block diagram figure 11-1 gives an overview of the intc. the grey boxes represent registers that can be accessed via the user interface. the interrupt requests from the peripherals (ireqn) and the nmi are input on the left side of the figure. signals to and from the cpu are on the right side of the figure.
175 32117b?avr-03/11 at32uc3c figure 11-1. intc block diagram 11.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 11.4.1 power management if the cpu enters a sleep mode that disables clk_sync, the intc will stop functioning and resume operation after the system wakes up from sleep mode. 11.4.2 clocks the clock for the intc bus interface (clk_intc) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. the intc sampling logic runs on a clock which is stopped in any of the sleep modes where the system rc oscillator is not running. this cl ock is referred to as clk_sync. this clock is enabled at reset, and only turned off in sleep modes wher e the system rc oscillator is stopped. 11.4.3 debug operation when an external debugger forces the cpu into debug mode, the intc continues normal operation. 11.5 functional description all of the incoming interrupt requests (ireqs) are sampled into the corresponding interrupt request register (irr). the irrs must be accessed to identify which ireq within a group that is active. if several ireqs within the same group are active, the interrupt service routine must prioritize between them. all of the input lines in each group are logically ored together to form the grpreqn lines, indicating if there is a pending interrupt in the corresponding group. the request masking hardware maps each of the grpreq lines to a priority level from int0 to int3 by associating each grou p with the interrupt level (int level) field in the corresponding request masking or ireq0 ireq1 ireq2 ireq31 grpreq0 masks sreg masks i[3-0]m gm intlevel autovector prioritizer cpu interrupt controller or grpreqn nmireq or ireq32 ireq33 ireq34 ireq63 grpreq1 irr registers ipr registers icr registers int_level, offset int_level, offset int_level, offset ipr0 ipr1 iprn irr0 irr1 irrn valreq0 valreq1 valreqn . . . . . . . . .
176 32117b?avr-03/11 at32uc3c interrupt priority register (ipr). the grpreq inputs are then masked by the mask bits from the cpu status register. any interrupt group that has a pending interrupt of a priority level that is not masked by the cpu status register, gets its corresponding valreq line asserted. masking of the interrupt requests is done based on five interrupt mask bits of the cpu status register, namely interrupt level 3 mask (i3m) to interrupt level 0 mask (i0m), and global inter- rupt mask (gm). an interrupt request is masked if either the gm or the corresponding interrupt level mask bit is set. the prioritizer hardware uses th e valreq lines and the intlevel fi eld in the iprs to select the pending interrupt of the highest priority. if an nm i interrupt request is pending, it automatically gets the highest priority of any pending interrupt. if several interrupt groups of the highest pend- ing interrupt level have pending interrupts, the interrupt group with the lowest number is selected. the intlevel and handler autovector offset (autovector) of the selected interrupt are transmitted to the cpu for interrupt handling an d context switching. the cpu does not need to know which interrupt is requesting handling, but only the level and the offset of the handler address. the irr registers contain the interrupt request lines of the groups and can be read via user interface registers for checking which interrupts of the group are actually active. the delay through the intc from the peripheral interrupt request is set until the interrupt request to the cpu is set is three cycles of clk_sync. 11.5.1 non-maskable interrupts a nmi request has priority over all other interrupt requests. nmi has a dedicated exception vec- tor address defined by the avr32 architec ture, so autovector is undefined when intlevel indicates that an nmi is pending. 11.5.2 cpu response when the cpu receives an interr upt request it checks if any othe r exceptions are pending. if no exceptions of higher priority are pending, interr upt handling is initiated. when initiating interrupt handling, the corresponding interrupt mask bit is se t automatically for this and lower levels in sta- tus register. e.g, if an interrupt of level 3 is approved for handling, the interrupt mask bits i3m, i2m, i1m, and i0m are set in status register. if an interrupt of level 1 is approved, the masking bits i1m and i0m are set in status register. th e handler address is calculated by logical or of the autovector to the cpu system register exception vector base address (evba). the cpu will then jump to the calculated address and start executing th e interrupt handler. setting the interrupt mask bits prevents the interrupts from the same and lower levels to be passed through the interrupt controller. setting of the same level mask bit prevents also multiple requests of the same interrupt to happen. it is the responsibility of the ha ndler software to clear the interrupt request that caused the inter- rupt before returning from the interrupt handler. if the conditions that caused the interrupt are not cleared, the interrupt request remains active. 11.5.3 clearing an interrupt request clearing of the interrupt request is done by writing to registers in the corresponding peripheral module, which then clears the corresponding nmireq/ireq signal. the recommended way of clearing an interrupt request is a store operation to the controlling peripheral register, followed by a dummy load operat ion from the same register. this causes a
177 32117b?avr-03/11 at32uc3c pipeline stall, which prevents the interrupt from accidentally re-triggering in case the handler is exited and the interrupt mask is cleared before the interrupt request is cleared.
178 32117b?avr-03/11 at32uc3c 11.6 user interface table 11-1. intc register memory map offset register register name access reset 0x000 interrupt priority register 0 ipr0 read/write 0x00000000 0x004 interrupt priority register 1 ipr1 read/write 0x00000000 ... ... ... ... ... 0x0fc interrupt priority register 63 ipr63 read/write 0x00000000 0x100 interrupt request register 0 irr0 read-only n/a 0x104 interrupt request register 1 irr1 read-only n/a ... ... ... ... ... 0x1fc interrupt request regi ster 63 irr63 read-only n/a 0x200 interrupt cause register 3 icr3 read-only n/a 0x204 interrupt cause register 2 icr2 read-only n/a 0x208 interrupt cause register 1 icr1 read-only n/a 0x20c interrupt cause register 0 icr0 read-only n/a
179 32117b?avr-03/11 at32uc3c 11.6.1 interrupt priority registers name : ipr0...ipr63 access type: read/write offset: 0x000 - 0x0fc reset value: 0x00000000 ? intlevel: interrupt level indicates the evba-relative offs et of the interrup t handler of the co rresponding group: 00: int0: lowest priority 01: int1 10: int2 11: int3: highest priority ? autovector: autovector address handler offset is used to give the address of the interrupt handle r. the least significant bit should be written to zero to giv e halfword alignment. 31 30 29 28 27 26 25 24 intlevel[1:0] ------ 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - autovector[13:8] 76543210 autovector[7:0]
180 32117b?avr-03/11 at32uc3c 11.6.2 interrupt request registers name : irr0...irr63 access type: read-only offset: 0x0ff - 0x1fc reset value: n/a ? irr: interrupt request line this bit is cleared when no interrupt request is pending on this input request line. this bit is set when an interrupt request is pending on this input request line. the are 64 irrs, one for each group. each irr has 32 bits, one for each possible interrupt request, for a total of 2048 possibl e input lines. the irrs are read by the software interrupt handler in order to determine which interrupt request is pending. the irrs are sampled continuously, and are read-only. 31 30 29 28 27 26 25 24 irr[32*x+31] irr[32*x+30] irr[32*x+ 29] irr[32*x+28] irr[32* x+27] irr[32*x+26] irr[32*x+25] irr[32*x+24] 23 22 21 20 19 18 17 16 irr[32*x+23] irr[32*x+22] irr[32*x+ 21] irr[32*x+20] irr[32* x+19] irr[32*x+18] irr[32*x+17] irr[32*x+16] 15 14 13 12 11 10 9 8 irr[32*x+15] irr[32*x+14] irr[32*x+ 13] irr[32*x+12] irr[32*x+ 11] irr[32*x+10] irr[32*x+9] irr[32*x+8] 76543210 irr[32*x+7] irr[32*x+6] irr[32*x+5] irr[32*x+4] irr[32*x+3] irr[32*x+2] irr[32*x+1] irr[32*x+0]
181 32117b?avr-03/11 at32uc3c 11.6.3 interrupt cause registers name : icr0...icr3 access type: read-only offset: 0x200 - 0x20c reset value: n/a ? cause: interrupt group causing interrupt of priority n icrn identifies the group with the highest pr iority that has a pending interrupt of le vel n. this value is only defined when at least one interrupt of level n is pending. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -- cause
182 32117b?avr-03/11 at32uc3c 11.7 interrupt r equest signal map the various modules may output interrupt request signals. these signals are routed to the inter- rupt controller (intc), described in a later c hapter. the interrupt controller supports up to 64 groups of interrupt requests. each group can have up to 32 interrupt request signals. all interrupt signals in the same group share the same autov ector address and priority level. refer to the documentation for the individual submodules for a description of the semantics of the different interrupt requests. the interrupt request signals are co nnected to the intc as follows. table 11-2. interrupt request signal map group line module signal 0 0 avr32uc3 cpu sysblock compare 1 0 avr32uc3 cpu ocd dcemu dirty 1 avr32uc3 cpu ocd dccpu read 2 0 secure access unit sau 3 0 peripheral dma controller pdca 0 1 peripheral dma controller pdca 1 2 peripheral dma controller pdca 2 3 peripheral dma controller pdca 3 4 0 peripheral dma controller pdca 4 1 peripheral dma controller pdca 5 2 peripheral dma controller pdca 6 3 peripheral dma controller pdca 7 5 0 peripheral dma controller pdca 8 1 peripheral dma controller pdca 9 2 peripheral dma controller pdca 10 3 peripheral dma controller pdca 11 6 0 peripheral dma controller pdca 12 1 peripheral dma controller pdca 13 2 peripheral dma controller pdca 14 3 peripheral dma controller pdca 15 7 0 memory dma mdma 8 0 usb 2.0 otg interface usbc
183 32117b?avr-03/11 at32uc3c 9 0 control area network interface canif boff 0 1 control area network interface canif error 0 2 control area network interface canif rxok 0 3 control area network interface canif txok 0 4 control area network interface canif wakeup 0 5 control area network interface canif boff 1 6 control area network interface canif error 1 7 control area network interface canif rxok 1 8 control area network interface canif txok 1 9 control area network interface canif wakeup 1 10 0 flash controller hflashc 11 0 sdram controller sdramc 12 0 power manager pm 13 0 system control interface scif 14 0 asynchronous timer ast alarm 1 asynchronous timer ast clkready 2 asynchronous timer ast ovf 3 asynchronous timer ast per 4 asynchronous timer ast ready 15 0 external interrupt controller eic 1 1 external interrupt controller eic 2 2 external interrupt controller eic 3 3 external interrupt controller eic 4 16 0 external interrupt controller eic 5 1 external interrupt controller eic 6 2 external interrupt controller eic 7 3 external interrupt controller eic 8 17 0 frequency meter freqm table 11-2. interrupt request signal map
184 32117b?avr-03/11 at32uc3c 18 0 general purpose input/ou tput controller gpio 0 1 general purpose input/ou tput controller gpio 1 2 general purpose input/ou tput controller gpio 2 3 general purpose input/ou tput controller gpio 3 4 general purpose input/ou tput controller gpio 4 5 general purpose input/ou tput controller gpio 5 6 general purpose input/ou tput controller gpio 6 7 general purpose input/ou tput controller gpio 7 8 general purpose input/ou tput controller gpio 8 9 general purpose input/ou tput controller gpio 9 10 general purpose input/ou tput controller gpio 10 11 general purpose input/ou tput controller gpio 11 12 general purpose input/ou tput controller gpio 12 13 general purpose input/ou tput controller gpio 13 14 general purpose input/ou tput controller gpio 14 15 general purpose input/ou tput controller gpio 15 19 0 universal synchronous/asynchronous receiver/transmitter usart0 20 0 universal synchronous/asynchronous receiver/transmitter usart1 21 0 universal synchronous/asynchronous receiver/transmitter usart2 22 0 universal synchronous/asynchronous receiver/transmitter usart3 23 0 serial peripheral interface spi0 24 0 serial peripheral interface spi1 25 0 two-wire master interface twim0 26 0 two-wire master interface twim1 27 0 two-wire slave interface twis0 28 0 two-wire slave interface twis1 29 0 inter-ic sound (i2s) controller iisc 30 0 pulse width modulation controller pwm 31 0 quadrature decoder qdec0 32 0 quadrature decoder qdec1 33 0 timer/counter tc00 1 timer/counter tc01 2 timer/counter tc02 table 11-2. interrupt request signal map
185 32117b?avr-03/11 at32uc3c 34 0 timer/counter tc10 1 timer/counter tc11 2 timer/counter tc12 35 0 peripheral event controller pevc tr 1 peripheral event controller pevc ov 36 0 adc controller interface with touch screen functionality adcifa seq0 1 adc controller interface with touch screen functionality adcifa seq1 2 adc controller interface with touch screen functionality adcifa sutd 3 adc controller interface with touch screen functionality adcifa window 4 adc controller interface with touch screen functionality adcifa awakeup 5 adc controller interface with touch screen functionality adcifa pendet 37 0 analog comparators interface acifa0 38 0 analog comparators interface acifa1 39 0dac interface dacifb0 chb underrun 1dac interface dacifb0 chb overrun 2dac interface dacifb0 chb data empty 3dac interface dacifb0 cha underrun 4dac interface dacifb0 cha overrun 5dac interface dacifb0 cha data empty 40 0dac interface dacifb1 cha data empty 1dac interface dacifb1 cha overrun 2dac interface dacifb1 cha underrun 3dac interface dacifb1 chb data empty 4dac interface dacifb1 chb overrun 5dac interface dacifb1 chb underrun table 11-2. interrupt request signal map
186 32117b?avr-03/11 at32uc3c 41 0 awire aw 42 0 ethernet mac macb 44 0 universal synchronous/asynchronous receiver/transmitter usart4 45 0 two-wire master interface twim2 46 0 two-wire slave interface twis2 table 11-2. interrupt request signal map
187 32117b?avr-03/11 at32uc3c 12. external interrupt controller (eic) rev: 3.0.2.0 12.1 features ? dedicated interrupt requ est for each interrupt ? individually maskable interrupts ? interrupt on rising or falling edge ? interrupt on high or low level ? asynchronous interrupts fo r sleep modes without clock ? filtering of interrupt lines ? non-maskable nmi interrupt 12.2 overview the external interrupt controller (eic) allows pins to be configured as external interrupts. each external interrupt has its own interrupt request and can be individually masked. each external interrupt can generate an interrupt on rising or falling edge, or high or low level. every interrupt input has a configurable filter to remove spikes from the interrupt source. every interrupt pin can also be configured to be asynchronous in order to wake up the part from sleep modes where the clk_sync clock has been disabled. a non-maskable interrupt (nmi) is also supported. this has the same properties as the other external interrupts, but is connected to the nmi request of the cpu, enabling it to interrupt any other interrupt mode. the eic can wake up the part from sleep modes without triggering an interrupt. in this mode, code execution starts from the instruction following the sleep instruction. 12.3 block diagram figure 12-1. eic block diagram edge/level detector mask irqn extintn nmi intn level mode edge ier idr icr ctrl isr im r filter filter polarity control level mode edge asynchronus detector eic_wake enable en dis ctrl clk_sync wake detect async
188 32117b?avr-03/11 at32uc3c 12.4 i/o lines description 12.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 12.5.1 i/o lines the external interrupt pins (extintn and nmi) may be multiplexed with i/o controller lines. the programmer must first program the i/o controller to assign the desired eic pins to their periph- eral function. if i/o lines of the eic are not used by the application, they can be used for other purposes by the i/o controller. it is only required to enable the eic inputs actually in use. if an application requires two external interrupts, then only two i/o lines will be a ssigned to eic inputs. 12.5.2 power management all interrupts are available in all sleep modes as long as the eic module is powered. however, in sleep modes where clk_sync is stopped, the interrupt must be configured to asynchronous mode. 12.5.3 clocks the clock for the eic bus interface (clk_eic) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. the filter and synchronous edge/level detector runs on a clock which is stopped in any of the sleep modes where the system rc osc illator (rcsys) is not running. this clock is referred to as clk_sync. 12.5.4 interrupts the external interrupt request lines are connected to the interrupt controller. using the external interrupts requires the interrupt controller to be programmed first. using the non-maskable interrupt does not require the interrupt controller to be programmed. 12.5.5 debug operation when an external debugger forces the cpu into debug mode, the eic continues normal opera- tion. if the eic is configured in a way that r equires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. 12.6 functional description 12.6.1 external interrupts the external interrupts are not enabled by default, allowing the proper interrupt vectors to be set up by the cpu before the interrupts are enabled. table 12-1. i/o lines description pin name pin description type nmi non-maskable interrupt input extintn external interrupt input
189 32117b?avr-03/11 at32uc3c each external interrupt intn can be configured to prod uce an interrup t on rising or falling edge, or high or low level. external interrupts ar e configured by the mode, edge, and level regis- ters. each interrupt has a bit intn in each of these registers. writing a zero to the intn bit in the mode register enables edge triggered interrupts, while writing a one to the bit enables level trig- gered interrupts. if intn is configured as an edge triggered interrupt, writing a zero to the intn bit in the edge register will cause the interrupt to be triggered on a falling edg e on extintn, while writing a one to the bit will cause the in terrupt to be triggered on a rising edge on extintn. if intn is configured as a leve l triggered interrupt, writing a zero to the intn bit in the level register will cause the interrupt to be triggered on a low level on extintn, while writing a one to the bit will cause the interrupt to be triggered on a high level on extintn. each interrupt has a corresponding bit in each of the interrupt control and status registers. writ- ing a one to the intn bit in the interrupt enabl e register (ier) enables the external interrupt from pin extintn to propagate from the eic to the interrupt controller, while writing a one to intn bit in the interrupt disable register (idr) disables this propagation. the interrupt mask register (imr) can be read to check which interrupts are enabled. when an interrupt triggers, the corresponding bit in th e interrupt status register (isr) will be set. this bit remains set until a one is written to the corresponding bit in the interrupt clear register (icr) or the interrupt is disabled. writing a one to the intn bit in the enable regist er (en) enables the external interrupt on pin extintn, while writing a one to intn bit in the disable register (dis) disables the external inter- rupt. the control register (ctrl) can be read to check which interrupts are enabled. if a bit in the ctrl register is set, but the corresponding bit in imr is not set, an interrupt will not propa- gate to the interrupt controller. however, the corresponding bit in isr will be set, and eic_wake will be set. note that an external inte rrupt should not be en abled before it has been configured correctly. if the ctrl.intn bit is zero, the corresponding bi t in isr will always be ze ro. disabling an exter- nal interrupt by writing a one to the dis.intn bit will clear the corresponding bit in isr. please refer to the module configuration section for the number of external interrupts. 12.6.2 synchronization and filtering of external interrupts in synchronous mode the pin value of the extintn pin is synchronized to clk_sync, so spikes shorter than one clk_sync cycle are not guaranteed to produce an interrupt. the syn- chronization of the extintn to clk_sync will delay the propagation of the interrupt to the interrupt controller by two cycles of clk_sync, see figure 12-2 and figure 12-3 for examples (filter off). it is also possible to apply a filter on extintn by writing a one to the intn bit in the filter reg- ister. this filter is a majority voter, if the condition for an interrupt is true for more than one of the latest three cycles of clk_sync the interrup t will be set. this will additionally delay the propa- gation of the interrupt to the interrupt controller by one or two cycles of clk_sync, see figure 12-2 and figure 12-3 for examples (filter on).
190 32117b?avr-03/11 at32uc3c figure 12-2. timing diagram, synchronous interr upts, high level or rising edge figure 12-3. timing diagram, synchrono us interrupts, low level or falling edge 12.6.3 non-maskable interrupt the nmi supports the same features as the external interrupts, and is accessed through the same registers. th e description in section 12.6.1 should be followed, accessing the nmi bit instead of the intn bits. the nmi is non-maskable within the cpu in the sense that it can interrupt any other execution mode. still, as for the other exte rnal interrupts, the actual nmi input can be enabled an d disabled by accessing the registers in the eic. 12.6.4 asynchronous interrupts each external inte rrupt can be made asynchronous by wr iting a one to intn in the async reg- ister. this will route the interrupt signal through the asynchronous path of the module. all edge interrupts will be interpreted as leve l interrupts and the f ilter is disabled. if an interrupt is config- ured as edge triggered interr upt in asynchronous mode, a zero in edge.intn will be interpreted as low level, and a one in edge.intn will be inte rpreted as high level. eic_wake will be set immediately after the source triggers the interrupt, while the correspond- ing bit in isr and the interrupt to the interrupt controller will be set on the next rising edge of clk_sync. please refer to figure 12-4 on page 191 for details. extintn/nmi clk_sync isr.intn: filter off isr.intn: filter on extintn/nmi clk_sync isr.intn: filter off isr.intn: filter on
191 32117b?avr-03/11 at32uc3c when clk_sync is stopped only asynchronous interrupts remain active, and any short spike on this interrupt will wake up the device . eic_wake will restart clk_sync and isr will be updated on the first rising edge of clk_sync. figure 12-4. timing diagram, asynchronous interrupts 12.6.5 wakeup the external interrupts can be used to wake up the part from sleep modes. the wakeup can be interpreted in two ways. if the corresponding bit in imr is one, then the execution starts at the interrupt handler for this interrupt. if the bit in imr is zero, then the execution starts from the next instruction after the sleep instruction. extintn/nmi clk_sync is r .in tn: rising edge or high level eic_wake: rising edge or high level extintn/nmi clk_sync is r .in t n: rising edge or high level eic_wake: rising edge or high level
192 32117b?avr-03/11 at32uc3c 12.7 user interface note: 1. the reset value is device specific. please refer to th e module configuration section at the end of this chapter. table 12-2. eic register memory map offset register register name access reset 0x000 interrupt enable register ier write-only 0x00000000 0x004 interrupt disable register idr write-only 0x00000000 0x008 interrupt mask register imr read-only 0x00000000 0x00c interrupt status register isr read-only 0x00000000 0x010 interrupt clear register icr write-only 0x00000000 0x014 mode register mode read/write 0x00000000 0x018 edge register edge read/write 0x00000000 0x01c level register level read/write 0x00000000 0x020 filter register filter read/write 0x00000000 0x024 test register test read/write 0x00000000 0x028 asynchronous register async read/write 0x00000000 0x030 enable register en write-only 0x00000000 0x034 disable register dis write-only 0x00000000 0x038 control register ctrl read-only 0x00000000 0x3fc version register version read-only - (1)
193 32117b?avr-03/11 at32uc3c 12.7.1 interrupt enable register name: ier access type: write-only offset: 0x000 reset value: 0x00000000 ?intn: external interrupt n writing a zero to this bit has no effect. writing a one to this bit will set the corresponding bit in imr. please refer to the module configuration se ction for the number of external interrupts. ? nmi: non-maskable interrupt writing a zero to this bit has no effect. wrting a one to this bit will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
194 32117b?avr-03/11 at32uc3c 12.7.2 interrupt disable register name: idr access type: write-only offset: 0x004 reset value: 0x00000000 ?intn: external interrupt n writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in imr. please refer to the module configuration se ction for the number of external interrupts. ? nmi: non-maskable interrupt writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
195 32117b?avr-03/11 at32uc3c 12.7.3 interrupt mask register name: imr access type: read-only offset: 0x008 reset value: 0x00000000 ?intn: external interrupt n 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. please refer to the module configuration se ction for the number of external interrupts. ? nmi: non-maskable interrupt 0: the non-maskable in terrupt is disabled. 1: the non-maskable interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
196 32117b?avr-03/11 at32uc3c 12.7.4 interrupt status register name: isr access type: read-only offset: 0x00c reset value: 0x00000000 ?intn: external interrupt n 0: an interrupt event has not occurred. 1: an interrupt event has occurred. this bit is cleared by writing a one to the corresponding bit in icr. please refer to the module configuration se ction for the number of external interrupts. ? nmi: non-maskable interrupt 0: an interrupt event has not occurred. 1: an interrupt event has occurred. this bit is cleared by writing a one to the corresponding bit in icr. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
197 32117b?avr-03/11 at32uc3c 12.7.5 interrupt clear register name: icr access type: write-only offset: 0x010 reset value: 0x00000000 ?intn: external interrupt n writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in isr. please refer to the module configuration se ction for the number of external interrupts. ? nmi: non-maskable interrupt writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in isr. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
198 32117b?avr-03/11 at32uc3c 12.7.6 mode register name: mode access type: read/write offset: 0x014 reset value: 0x00000000 ?intn: external interrupt n 0: the external interrupt is edge triggered. 1: the external interrupt is level triggered. please refer to the module configuration se ction for the number of external interrupts. ? nmi: non-maskable interrupt 0: the non-maskable interrupt is edge triggered. 1: the non-maskable interrupt is level triggered. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
199 32117b?avr-03/11 at32uc3c 12.7.7 edge register name: edge access type: read/write offset: 0x018 reset value: 0x00000000 ?intn: external interrupt n 0: the external interrupt triggers on falling edge. 1: the external interrupt triggers on rising edge. please refer to the module configuration se ction for the number of external interrupts. ? nmi: non-maskable interrupt 0: the non-maskable interrupt triggers on falling edge. 1: the non-maskable interrupt triggers on rising edge. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
200 32117b?avr-03/11 at32uc3c 12.7.8 level register name: level access type: read/write offset: 0x01c reset value: 0x00000000 ?intn: external interrupt n 0: the external interrupt triggers on low level. 1: the external interrupt triggers on high level. please refer to the module configuration se ction for the number of external interrupts. ? nmi: non-maskable interrupt 0: the non-maskable interrupt triggers on low level. 1: the non-maskable interrupt triggers on high level. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
201 32117b?avr-03/11 at32uc3c 12.7.9 filter register name: filter access type: read/write offset: 0x020 reset value: 0x00000000 ?intn: external interrupt n 0: the external interrupt is not filtered. 1: the external interrupt is filtered. please refer to the module configuration se ction for the number of external interrupts. ? nmi: non-maskable interrupt 0: the non-maskable interrupt is not filtered. 1: the non-maskable interrupt is filtered. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
202 32117b?avr-03/11 at32uc3c 12.7.10 test register name: test access type: read/write offset: 0x024 reset value: 0x00000000 ? testen: test enable 0: this bit disables external interrupt test mode. 1: this bit enables extern al interrupt test mode. ?intn: external interrupt n writing a zero to this bit will set the input value to intn to zero, if test mode is enabled. writing a one to this bit will set the input value to intn to one, if test mode is enabled. please refer to the module configuration se ction for the number of external interrupts. ? nmi: non-maskable interrupt writing a zero to this bit will set the input value to nmi to zero, if test mode is enabled. writing a one to this bit will set the input value to nmi to one, if test mode is enabled. if testen is 1, the value written to this bit will be the value to the interrupt detector and the value on the pad will be igno red. 31 30 29 28 27 26 25 24 testenint30int29int28int27int26int25int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
203 32117b?avr-03/11 at32uc3c 12.7.11 asynchronous register name: async access type: read/write offset: 0x028 reset value: 0x00000000 ?intn: external interrupt n 0: the external interrupt is synchronized to clk_sync. 1: the external interrupt is asynchronous. please refer to the module configuration se ction for the number of external interrupts. ? nmi: non-maskable interrupt 0: the non-maskable interrupt is synchronized to clk_sync. 1: the non-maskable interrupt is asynchronous. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
204 32117b?avr-03/11 at32uc3c 12.7.12 enable register name: en access type: write-only offset: 0x030 reset value: 0x00000000 ?intn: external interrupt n writing a zero to this bit has no effect. writing a one to this bit will enable the corresponding external interrupt. please refer to the module configuration se ction for the number of external interrupts. ? nmi: non-maskable interrupt writing a zero to this bit has no effect. writing a one to this bit will enable the non-maskable interrupt. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
205 32117b?avr-03/11 at32uc3c 12.7.13 disable register name: dis access type: write-only offset: 0x034 reset value: 0x00000000 ?intn: external interrupt n writing a zero to this bit has no effect. writing a one to this bit will disable the corresponding external interrupt. please refer to the module configuration se ction for the number of external interrupts. ? nmi: non-maskable interrupt writing a zero to this bit has no effect. writing a one to this bit will disable the non-maskable interrupt. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
206 32117b?avr-03/11 at32uc3c 12.7.14 control register name: ctrl access type: read-only offset: 0x038 reset value: 0x00000000 ?intn: external interrupt n 0: the corresponding external interrupt is disabled. 1: the corresponding external interrupt is enabled. please refer to the module configuration se ction for the number of external interrupts. ? nmi: non-maskable interrupt 0: the non-maskable in terrupt is disabled. 1: the non-maskable interrupt is enabled. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
207 32117b?avr-03/11 at32uc3c 12.7.15 version register name: version access type: read-only offset: 0x3fc reset value: - ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
208 32117b?avr-03/11 at32uc3c 12.8 module configuration the specific configuration for each eic instance is listed in the following tables. the module bus clocks listed here are connecte d to the system bus clocks. pleas e refer to the power manager chapter for details. table 12-3. module configuration feature eic number of external interrupts, including nmi 9 table 12-4. module clock name module name clock name description eic clk_eic peripheral bus clock from the pba clock domain table 12-5. register reset values register reset value version 0x00000302
209 32117b?avr-03/11 at32uc3c 13. frequency meter (freqm) rev: 3.1.0.1 13.1 features ? accurately measures a clock frequency ? selectable reference clock ? a selectable clock can be measured ? ratio can be measured with 24-bit accuracy 13.2 overview the frequency meter (freqm) can be used to accurately measure the frequency of a clock by comparing it to a known reference clock. 13.3 block diagram figure 13-1. frequency meter block diagram 13.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 13.4.1 power management the device can enter a sleep mode while a measurement is ongoing. however, make sure that neither clk_msr nor clk_ref is stopped in the actual sleep mode. freqm interrupts can wake up the device from sleep modes when the measurement is done, but only from sleep modes where clk_freqm is running. please refe r to the power manager chapter for details. counter clk_ref clk_msr refsel refnum, start clksel start value timer trigger isr
210 32117b?avr-03/11 at32uc3c 13.4.2 clocks the clock for the freqm bus interface (clk_freqm) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to disable the freqm before disabling the clock, to avoid freezing the freqm ia an undefined state. a set of clocks can be selected as referenc e (clk_ref) and another set of clocks can be selected for measurement (clk_msr). please refer to the clksel and refsel tables in the module configuration section for details. 13.4.3 debug operation when an external debugger forces the cpu in to debug mode, the freqm continues normal operation. if the freqm is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. 13.4.4 interrupts the freqm interrupt request line is connected to the internal source of the interrupt controller. using the freqm interrupt requires the interrupt controller to be programmed first. 13.5 functional description the freqm accuratly measures the frequency of a clock by comparing the frequency to a known frequency: f clk_msr = (value/refnum)*f clk_ref 13.5.1 reference clock the reference clock selection (refsel) field in the mode register (mode) selects the clock source for clk_ref. the reference clock is enabled by writing a one to the reference clock enable (refcen) bit in the mode register. this clock should have a known frequency. clk_ref needs to be disabled before switching to another clock. the rclkbusy bit in the status register (sr) indicates whether the clock is busy or not. this bit is set when the mode.refcen bit is written. to change clk_ref: ? write a zero to the mode.refcen bit to disable the clock, without changing the other bits/fields in the mode register. ? wait until the sr.rclkbusy bit reads as zero. ? change the mode.refsel field. ? write a one to the mode.refcen bit to enable the clock, without changing the other bits/fields in the mode register. ? wait until the sr.rclkbusy bit reads as zero. to enable clk_ref: ? write the correct value to the mode.refsel field. ? write a one to the mode.refcen to enable the clock, without changing the other bits/fields in the mode register. ? wait until the sr.rclkbusy bit reads as zero. to disable clk_ref:
211 32117b?avr-03/11 at32uc3c ? write a zero to the mode.refcen to disable he clock, without changing the other bits/fields in the mode register. ? wait until the sr.rclkbusy bit reads as zero. 13.5.1.1 cautionary note note that if clock selected as source for clk_ref is stopped during a measurement, this will not be detected by the freqm. the busy bit in the status register w ill never be cleared, and the done interrupt will never be triggered. if the clock select ed as soruce for clk_ref is stopped, it will not be po ssible to change the source for th e reference clock as long as the selected source is not running. 13.5.2 measurement in the mode register the clock source sele ction (clksel) field selects clk_msr and the number of reference clock cycles (refnum) fi eld selects the duration of the measurement. the duration is given in number of clk_ref periodes. writing a one to the start bit in the control register (ctrl) starts the measurement. the busy bit in sr is cleared when the measurement is done. the result of the measurement can be read from the value register (value). the frequency of the measured clock clk_msr is then: f clk_msr = (value/refnum)*f clk_ref 13.5.3 interrupts the freqm has two interrupt sources: ? done: a frequency measurement is done ? rclkrdy: the reference clock is ready these will generate an interrupt request if the corresponding bit in the interrupt mask register (imr) is set. the interrupt sources are ored together to form one interrupt request. the freqm will generate an interrupt request if at least one of the bits in the interr upt mask register (imr) is set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier) and cleared by writing a one to this bit in the interrupt disable register (idr). the interrupt request remains active until the corresponding bit in the interrupt status register (isr) is cleared by writing a one to this bit in the interrupt clear register (icr). because all the interrupt sources are ored t ogether, the interrupt reque st from the freqm will rema in active until all the bits in isr are cleared.
212 32117b?avr-03/11 at32uc3c 13.6 user interface note: 1. the reset value for this register is device specific. please refer to the module configuration section at the end of thi s chapter. table 13-1. freqm register memory map offset register register name access reset 0x000 control register ctrl write-only 0x00000000 0x004 mode register mode read/write 0x00000000 0x008 status register status read-only 0x00000000 0x00c value register value read-only 0x00000000 0x010 interrupt enable register ier write-only 0x00000000 0x014 interrupt disable register idr write-only 0x00000000 0x018 interrupt mask register imr read-only 0x00000000 0x01c interrupt status register isr read-only 0x00000000 0x020 interrupt clear register icr write-only 0x00000000 0x3fc version register version read-only - (1)
213 32117b?avr-03/11 at32uc3c 13.6.1 control register name: ctrl access type: write-only offset: 0x000 reset value: 0x00000000 ?start writing a zero to this bit has no effect. writing a one to this bit will start a measurement. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------start
214 32117b?avr-03/11 at32uc3c 13.6.2 mode register name: mode access type: read/write offset: 0x004 reset value: 0x00000000 ? refcen: reference clock enable 0: the reference clock is disabled 1: the reference clock is enabled ? clksel: clock source selection selects the source for clk_msr. see table in module configuration chapter for details. ? refnum: number of reference clock cycles selects the duration of a measurement, given in number of clk_ref cycles. ? refsel: reference clock selection selects the source for clk_ref. see table in module configuration chapter for details. 31 30 29 28 27 26 25 24 refcen------- 23 22 21 20 19 18 17 16 - - - clksel 15 14 13 12 11 10 9 8 refnum 76543210 - - - - - refsel
215 32117b?avr-03/11 at32uc3c 13.6.3 status register name: status access type: read-only offset: 0x008 reset value: 0x00000000 ? rclkbusy: freqm reference clock status 0: the freqm ref clk is ready, so a measurement can start. 1: the freqm ref clk is not ready, so a measurement should not be started. ? busy: freqm status 0: the frequency meter is idle. 1: frequency measurement is on-going. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------rclkbusybusy
216 32117b?avr-03/11 at32uc3c 13.6.4 value register name: value access type: read-only offset: 0x00c reset value: 0x00000000 ? value: result from measurement. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 value[23:16] 15 14 13 12 11 10 9 8 value[15:8] 76543210 value[7:0]
217 32117b?avr-03/11 at32uc3c 13.6.5 interrupt enable register name: ier access type: write-only offset: 0x010 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------rclkrdydone
218 32117b?avr-03/11 at32uc3c 13.6.6 interrupt disable register name: idr access type: write-only offset: 0x014 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------rclkrdydone
219 32117b?avr-03/11 at32uc3c 13.6.7 interrupt mask register name: imr access type: read-only offset: 0x018 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------rclkrdydone
220 32117b?avr-03/11 at32uc3c 13.6.8 interrupt status register name: isr access type: read-only offset: 0x01c reset value: 0x00000000 0: the corresponding interrupt is cleared. 1: the corresponding interrupt is pending. a bit in this register is set when the corresponding bit in status has a one to zero transition. a bit in this register is cleared when the corresponding bit in icr is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------rclkrdydone
221 32117b?avr-03/11 at32uc3c 13.6.9 interrupt clear register name: icr access type: write-only offset: 0x020 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in isr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------rclkrdydone
222 32117b?avr-03/11 at32uc3c 13.6.10 version register name: version access type: read-only offset: 0x3fc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
223 32117b?avr-03/11 at32uc3c 13.7 module configuration the specific configuration for each freqm instance is listed in the following tables. the module bus clocks listed here are connected to the syst em bus clocks. please refer to the power man- ager chapter for details. table 13-2. module clock name module name clock name description freqm clk_freqm periphera l bus clock from the pba clock domain clk_msr measured clock clk_ref reference clock table 13-3. register reset values register reset value version 0x00000310 table 13-4. clock sources for clk_msr clks el clock/oscillator description 0 clk_cpu the clock the cpu runs on 1 clk_hsb high speed bus clock 2 clk_pba peripheral bus a clock 3 clk_pbb peripheral bus b clock 4 clk_pbc peripheral bus c clock 5 osc0 output clock from oscillator 0 6 osc1 output clock from oscillator 1 7 osc32k output clock from osc32k 8 rcsys output clock from rcsys oscillator 9 rc8m output clock from 8mhz / 1mhz rc oscillator 13-24 gclk0-11 generic clock 0 through 11 25 rc120m output clock from rc120m 26-31 reserved table 13-5. clock sources for clk_ref refsel clock/oscillator description 0 rcsys system 115 khz rc oscillator clock 1 osc32k output clock from osc32k 2 osc0 output clock from oscillator 0
224 32117b?avr-03/11 at32uc3c 3 osc1 output clock from oscillator 1 4 rc8m output clock from 8m hz / 1mhz rc oscillator 5 gclk9 generic clock 9 6-7 reserved table 13-5. clock sources for clk_ref refsel clock/oscillator description
225 32117b?avr-03/11 at32uc3c 14. peripheral even t controller (pevc) rev: 1.0.0.0 14.1 features ? direct peripheral to peri pheral communication system ? allows peripherals to receive, react to, and send peripheral events without cpu intervention ? cycle deterministic event communication ? asynchronous interrupts allow advanced peri pheral operation in low power sleep modes 14.2 overview many peripheral modules can be configured to emit or respond to signals known as peripheral events. the exact condition to trigger a peripheral event, or the action taken upon receiving a peripheral event, is specific to each module. peripherals that respond to events are called users and peripherals that emit events are called generators. a module may be both a generator and user. the peripheral event generators and users are interconnected by a network known as the peripheral event system. the peripheral event controller (pevc) controls the interconnection parameters, such as generator-to-user mult iplexing and peripheral event enable/disable. the peripheral even t system allows low late ncy peripheral-to-periphe ral signalling without cpu intervention, and without cons uming system resources such as bus or ram bandwidth. this offloads the cpu and system resources compared to a traditional interrupt-based software driven system. figure 14-1. peripheral event system overview peripheral event system generator generator user generator/ user
226 32117b?avr-03/11 at32uc3c 14.3 block diagram the main building blocks of the pevc are: ? event shapers (evs): instantiat ed for some generators, in case filtering and/or rising/falling edge detection is needed prior to peripheral event propagation ? channels: one channel per user, to propagate events and follow-up the user status to help distinguish the diffe rent signalling stages, these na ming conventions are used: ? generators generate events ? pevc multiplexes these incoming events ? pevc outputs triggers to users figure 14-2. pevc block diagram the maximum number of generators, event shapers, channels, and users supported by the peripheral event controller is 64. please refer to the module configuration section at the end of this chapter for the device-specific configuration. channel 0 channel ... channel n user 0 generator ... generator 0 evs 0 pevc user ... evt0 evs ... generator ... generator ... generator m user n rcsys clk_pevc trig0 trig... trign evt... evt... evt... evtm sev chmx rdy0 rdy... rdyn
227 32117b?avr-03/11 at32uc3c 14.4 i/o lines description 14.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 14.5.1 i/o lines multiplexed i/o lines can be used as event generators. to generate a peripheral event from an external source the source pin must be configured as an input pin by the i/o controller. it is also possible to trigger a peripheral event by driving these pins from registers in the i/o controller, or another peripheral output connected to the same pin. 14.5.2 power management if the cpu enters a sleep mode that disables clocks used by the pevc, the pevc will stop func- tioning and resume operation after the system wakes up from sleep mode. peripheral events do not require cpu intervention, and are therefore available in sleep modes where the cpu sleeps. 14.5.3 clocks the pevc has two bus clocks connected: one pe ripheral bus clock (clk_pevc) and the sys- tem rc oscillator clock (clk_rcsys). these clocks are generated by the power manager. both clocks are enabled at reset, and can be disabled by writing to the power manager. clk_rcsys is used for glitch filtering. 14.5.4 interrupts pevc can generate an interrupt request in case of trigger generation or trigger overrun. the pevc interrupt r equest lines are connected to the interr upt controller. using the pevc interrupts requires the interrupt controller to be programmed first. 14.5.5 debug operation pevc is frozen during debug operat ion, unless the run in debug bi t in the development control register is set and the bit corresponding to the pevc is set in the peripheral debug register (pdbg). please refer to the on-chip debug chapter in the avr32uc technical reference man- ual, and the ocd module configuration section, for details. table 14-1. i/o lines description pin name pin description type pad_evt[n] external event inputs input
228 32117b?avr-03/11 at32uc3c 14.6 functional description 14.6.1 pevc channel operation pevc routes incoming ev ents to users by mean s of one channel per user. cha nnels operate in parallel, allowing multip le users to listen to the same generator. 14.6.1.1 channel setup the channel multiplexer register (chmxn) is written to allocate a generator to a given channel. the event multiplexer field (evmx) selects between the different generators, while the software event multiplexer bit (smx) selects software events. the channel is then enabled by writing a one to the appropriate bit in the channel enable regis- ter (cher). it is disabled by writing a one to the appropriate bit in the channel disable register (chdr). to safely program a channel, user software must: ? disable the channel by writing a one to chdr ? program chmxn ? enable the channel by writing a one to cher 14.6.1.2 channel operation when the channel is enabled, the user signals its busy/ready state to the channel, to determine how an incoming event will be handled: ? if the user is ready, an incoming event is forwarded. the corresponding trigger status register (trisr) flag is set allowing an interrupt to be generated for tracking pevc operations. ? if the user is busy (because of a previous event, or for some other cause), the new event is not forwarded. the corresponding overrun status register (ovsr) flag is set allowing an interrupt to be generated. the busy register (busy) is used to determine the current activity of a channel/user. a busy status has one of two causes: ? a peripheral event is being relayed by the channel and handled by the user, ? no event relayed, but user is not ready (e.g. not initialized, or handling some other request). 14.6.1.3 software event a software event can be in itiated by software writ ing to the software event register (sev). this is intended for application debugging. the channel must first be programmed by writing a one to the software event multiplexer bit (smx) of chmxn. writing a one to the appropriat e bit of sev will then trigger a software event on the channel.
229 32117b?avr-03/11 at32uc3c 14.6.2 event shaper (evs) operation pevc contains event shapers (evs) for certain types of generators: ? asynchronous generators and/or external input ? general-purpose waveforms like timer outputs or generic clocks each event shaper is re sponsible of shaping on e input, prior to goin g through a pevc channel: ? synchronize asynchronous external inputs ? apply any additiona l glich-filtering ? detect rise, fall, or both edges of the incoming signal 14.6.2.1 input glitch filter (igf) input glitch filtering can be turned on or off by writing to the input glitch filter (igf) field of the corresponding event shaper register (evs). when igf is on, the incoming event is sampled periodically. the sampling clock is divided from clk_rcsys by the value of the inpu t glitch filter divider register (igfdr). igf will filter out spikes and propagate only incoming events that respect one of the following two conditions : ? rise event : 2 samples low, followed by 0+ changes, followed by 2 samples high ? fall event : 2 samples high, followed by 0+ changes, followed by 2 samples low both clk_rcsys and clk_pevc must be ena bled to use input glitch filtering. 14.6.3 event propagation latency once a channel is setup, incoming peripheral events are relayed by hardware. event progation latency is therefore cycle deterministic. however, its value depends on the exact settings that apply to a given channel. when the channel multiplexer chmxn.evmx selects a generator without event shaper, event propagation latency is 0 cycle. so ftware event is a particular case of 0 cycle propagation. when the channel multiplexer chmxn.evmx selects a generator with event shaper, event propagation latency depends on input glitch filter setting evsm.igf : ? igf off : event propagation latency is lesser or equal to 2 clk_pevc cycles ? igf on : event propagation latency is lesser or equal to 3 * 2 igfdr+1 * clk_rcsys cycles please refer to the module configuration section at the end of this chapter for the list of genera- tors implementing event shapers. table 14-2. event propagation latency generator chmxn.evmx input glitch filter evsm.igf latency clock generator without event shaper - 0 - software event - 0 - generator with event shaper off 2 clk_pevc generator with event shaper on 3 * 2 igfdr+1 clk_rcsys
230 32117b?avr-03/11 at32uc3c 14.7 user interface notes: 1. the reset values for these registers are device specific . please refer to the module configuration section at the end o f this chapter. 2. i={0,1}, where i=0 contains the lowest 32 channels, and i=1 contains the highest 32 channels. the lowest address contains register 0, the highest address contains r egister 1. register 1 is only implement ed if the device has more than 32 channels implemented. please refer to the module configuratio n section at the end of this chapter for details. pevc register memory map offset register register name access reset 0x000 version version read-only - (1) 0x004 parameter parameter read-only - (1) 0x008 input glitch filter divider register igfdr read/write 0x00000000 0x010 - 0x014 channel status register chsri (2) read-only 0x00000000 0x020 - 0x024 channel enable register cheri (2) write-only - 0x030 - 0x034 channel disable register chdri (2) write-only - 0x040 - 0x044 software event sevi (2) write-only - 0x050 - 0x054 channel / user busy busyi (2) read-only - (1) 0x060 - 0x064 trigger status register trsri (2) read-only 0x00000000 0x070 - 0x074 trigger status clear register trscri (2) write-only - 0x080 - 0x084 trigger interrupt mask register trimri (2) read-only 0x00000000 0x090 - 0x094 trigger interrupt mask enable register trieri (2) write-only - 0x0a0 - 0x0a4 trigger interrupt mask disable register tridri (2) write-only - 0x0b0 - 0x0b4 overrun status register ovsri (2) read-only 0x00000000 0x0c0 - 0x0c4 overrun status clear register ovscri (2) write-only - 0x0d0 - 0x0d4 overrun interrupt mask register ovimri (2) read-only 0x00000000 0x0e0 - 0x0e4 overrun interrupt mask enable register ovieri (2) write-only - 0x0f0 - 0x0f4 overrun interrupt mask disable register ovidri (2) write-only - 0x100 channel multiplexer 0 chmx0 read/write 0x00000000 0x100 + n*0x004 channel multiplexer n chmxn read/write 0x00000000 0x1fc channel multiplexer 63 chmx63 read/write 0x00000000 0x200 event shaper 0 evs0 read/write 0x00000000 0x200 + m*0x004 event shaper m evsm read/write 0x00000000 0x2fc event shaper 63 evs63 read/write 0x00000000
231 32117b?avr-03/11 at32uc3c 14.7.1 version register name: version access type: read-only offset: 0x000 reset value: - ? variant: variant number variant number of the module. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
232 32117b?avr-03/11 at32uc3c 14.7.2 parameter register name: parameter access type: read-only offset: 0x004 reset value: - ? trigout: number of trigger outputs / channels / users number of trigger outputs / channels implemented. no functionality associated. ? evmx: number of bits to contro l evmx field in chmxn registers number of multiplexers control bits, derived from evin. no functionality associated. ? evs: number of event shapers number of event shapers implement ed. no functionality associated. ? evin: number of event inputs / generators number of event inputs. no functionality associated. 31 30 29 28 27 26 25 24 trigout 23 22 21 20 19 18 17 16 evmx 15 14 13 12 11 10 9 8 evs 76543210 evin
233 32117b?avr-03/11 at32uc3c 14.7.3 input glitch filter divider register name: igfdr access type: read/write offset: 0x008 reset value: 0x00000000 ? igfdr: input glitch filter divider selects prescaler division ratio for the system rc clock used for glitch filtering. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ---- igfdr igfdr division ratio 0x0 2 0x1 4 0x2 8 0xn 2 n+1 0xf 65536
234 32117b?avr-03/11 at32uc3c 14.7.4 channel status register name: chsr0 - chsr1 access type: read-only offset: 0x010 - 0x014 reset value: 0x00000000 ? chs: channel status 0: the corresponding channel is disabled. 1: the corresponding channel is enabled. this bit is cleared when the corresponding bit in chdr is written to one. this bit is set when the corresponding bit in cher is written to one. note: channels 0 to 31 are controlled by chsr0. channels 32 to 63 are controlled by chsr1. please refer to the module configuration section at the end of this chapter for device-specific channel mapping information. 31 30 29 28 27 26 25 24 chs 23 22 21 20 19 18 17 16 chs 15 14 13 12 11 10 9 8 chs 76543210 chs
235 32117b?avr-03/11 at32uc3c 14.7.5 channel enable register name: cher0 - cher1 access type: write-only offset: 0x020 - 0x024 reset value: - ? che: channel enable writing a zero to this bit has no effect. writing a one to this bit will set the corresponding bit in chsr. note: channels 0 to 31 are controlled by cher0. channels 32 to 63 are controlled by cher1. please refer to the module configuration section at the end of this chapter for device-specific channel mapping information. 31 30 29 28 27 26 25 24 che 23 22 21 20 19 18 17 16 che 15 14 13 12 11 10 9 8 che 76543210 che
236 32117b?avr-03/11 at32uc3c 14.7.6 channel disable register name: chdr0 - chdr1 access type: write-only offset: 0x030 - 0x034 reset value: - ? chd: channel disable writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in chsr. note: channels 0 to 31 are controlled by cher0. channels 32 to 63 are controlled by cher1. please refer to the module configuration section at the end of this chapter for device-specific channel mapping information. 31 30 29 28 27 26 25 24 chd 23 22 21 20 19 18 17 16 chd 15 14 13 12 11 10 9 8 chd 76543210 chd
237 32117b?avr-03/11 at32uc3c 14.7.7 software event register name: sev0 - sev1 access type: write-only offset: 0x040 - 0x044 reset value: - ? sev: software event writing a zero to this bit has no effect. writing a one to this bit will trigger a software event for the corresponding channel. note: channels 0 to 31 are controlled by sev0. channels 32 to 63 are controlled by sev1. please refer to the module configuration section at the end of this chapter for device-specific channel mapping information. 31 30 29 28 27 26 25 24 sev 23 22 21 20 19 18 17 16 sev 15 14 13 12 11 10 9 8 sev 76543210 sev
238 32117b?avr-03/11 at32uc3c 14.7.8 channel / user busy name: busy0 - busy1 access type: read-only offset: 0x050 - 0x054 reset value: - ? busy: channel status 0: the corresponding channel and user are idle. 1: the corresponding channel and user are busy. note: channels 0 to 31 are controlled by busy0. channels 32 to 63 are controlled by busy1. please refer to the module configuration section at the end of this chapter for device-specific channel mapping information. 31 30 29 28 27 26 25 24 busy 23 22 21 20 19 18 17 16 busy 15 14 13 12 11 10 9 8 busy 76543210 busy
239 32117b?avr-03/11 at32uc3c 14.7.9 trigger status register name: trsr0 - trsr1 access type: read-only offset: 0x060 - 0x064 reset value: 0x00000000 ? trs: trigger interrupt status 0: an interrupt event has not occurred 1: an interrupt event has occurred this bit is cleared by writing a one to the corresponding bit in trscr. note: channels 0 to 31 are controlled by trsr0. channels 32 to 63 are controlled by trsr1. please refer to the module configuration section at the end of this chapter for device-specific channel mapping information. 31 30 29 28 27 26 25 24 trs 23 22 21 20 19 18 17 16 trs 15 14 13 12 11 10 9 8 trs 76543210 trs
240 32117b?avr-03/11 at32uc3c 14.7.10 trigger status clear register name: trscr0 - trscr1 access type: write-only offset: 0x070 - 0x074 reset value: - ? trsc: trigger interrupt status clear writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in trsr. note: channels 0 to 31 are controlled by trscr0. channels 32 to 63 are controlled by trscr1. please refer to the module configuration section at the end of this chapter for device-specific channel mapping information. 31 30 29 28 27 26 25 24 trsc 23 22 21 20 19 18 17 16 trsc 15 14 13 12 11 10 9 8 trsc 76543210 trsc
241 32117b?avr-03/11 at32uc3c 14.7.11 trigger interrupt mask register name: trimr0 - trimr1 access type: read-only offset: 0x080 - 0x084 reset value: 0x00000000 ? trim: trigger interrupt mask 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in tridr is written to one. this bit is set when the corresponding bit in trier is written to one. note: channels 0 to 31 are controlled by trimr0. channels 32 to 63 are controlled by trimr1. please refer to the module configuration section at the end of this chapter for device-specific channel mapping information. 31 30 29 28 27 26 25 24 trim 23 22 21 20 19 18 17 16 trim 15 14 13 12 11 10 9 8 trim 76543210 trim
242 32117b?avr-03/11 at32uc3c 14.7.12 trigger interrupt enable register name: trier0 - trier1 access type: write-only offset: 0x090 - 0x094 reset value: - ? trie: trigger interrupt enable writing a zero to this bit has no effect. writing a one to this bit will set the corresponding bit in trimr. note: channels 0 to 31 are controlled by trier0. channels 32 to 63 are controlled by trier1. please refer to the module configuration section at the end of this chapter for device-specific channel mapping information. 31 30 29 28 27 26 25 24 trie 23 22 21 20 19 18 17 16 trie 15 14 13 12 11 10 9 8 trie 76543210 trie
243 32117b?avr-03/11 at32uc3c 14.7.13 trigger interrupt disable register name: tridr0 - tridr1 access type: write-only offset: 0x0a0 - 0x0a4 reset value: - ? trid: trigger interrupt disable writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in imr. note: channels 0 to 31 are controlled by tridr0. channels 32 to 63 are controlled by tridr1. please refer to the module configuration section at the end of this chapter for device-specific channel mapping information. 31 30 29 28 27 26 25 24 trid 23 22 21 20 19 18 17 16 trid 15 14 13 12 11 10 9 8 trid 76543210 trid
244 32117b?avr-03/11 at32uc3c 14.7.14 overrun status register name: ovsr0 - ovsr1 access type: read-only offset: 0x0b0 - 0x0b4 reset value: 0x00000000 ? ovs: overrun in terrupt status 0: an interrupt event has not occurred 1: an interrupt event has occurred this bit is cleared by writing a one to the corresponding bit in ovscr. note: channels 0 to 31 are controlled by ovsr0. channels 32 to 63 are controlled by ovsr1. please refer to the module configuration section at the end of this chapter for device-specific channel mapping information. 31 30 29 28 27 26 25 24 ovs 23 22 21 20 19 18 17 16 ovs 15 14 13 12 11 10 9 8 ovs 76543210 ovs
245 32117b?avr-03/11 at32uc3c 14.7.15 overrun status clear register name: ovscr0 - ovscr1 access type: write-only offset: 0x0c0 - 0x0c4 reset value: - ? ovsc: overrun inte rrupt status clear writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in ovsr. note: channels 0 to 31 are controlled by ovscr0. channels 32 to 63 are controlled by ovscr1. please refer to the module configuration section at the end of this chapter for device-specific channel mapping information. 31 30 29 28 27 26 25 24 ovsc 23 22 21 20 19 18 17 16 ovsc 15 14 13 12 11 10 9 8 ovsc 76543210 ovsc
246 32117b?avr-03/11 at32uc3c 14.7.16 overrun interrupt mask register name: ovimr0 - ovimr1 access type: read-only offset: 0x0d0 - 0x0d4 reset value: 0x00000000 ? ovim: overrun interrupt mask 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in ovidr is written to one. this bit is set when the corresponding bit in ovier is written to one. note: channels 0 to 31 are controlled by ovimr0. channels 32 to 63 are controlled by ovimr1. please refer to the module configuration section at the end of this chapter for device-specific channel mapping information. 31 30 29 28 27 26 25 24 ovim 23 22 21 20 19 18 17 16 ovim 15 14 13 12 11 10 9 8 ovim 76543210 ovim
247 32117b?avr-03/11 at32uc3c 14.7.17 overrun interrupt enable register name: ovier0 - ovier1 access type: write-only offset: 0x0e0 - 0x0e4 reset value: - ? ovie: overrun interrupt enable writing a zero to this bit has no effect. writing a one to this bit will set the corresponding bit in ovimr. note: channels 0 to 31 are controlled by ovier0. channels 32 to 63 are controlled by ovier1. please refer to the module configuration section at the end of this chapter for device-specific channel mapping information. 31 30 29 28 27 26 25 24 ovie 23 22 21 20 19 18 17 16 ovie 15 14 13 12 11 10 9 8 ovie 76543210 ovie
248 32117b?avr-03/11 at32uc3c 14.7.18 overrun interrupt disable register name: ovidr0 - ovidr1 access type: write-only offset: 0x0f0 - 0x0f4 reset value: - ? ovid: overrun interrupt disable writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in imr. note: channels 0 to 31 are controlled by ovidr0. channels 32 to 63 are controlled by ovidr1. please refer to the module configuration section at the end of this chapter for device-specific channel mapping information. 31 30 29 28 27 26 25 24 ovid 23 22 21 20 19 18 17 16 ovid 15 14 13 12 11 10 9 8 ovid 76543210 ovid
249 32117b?avr-03/11 at32uc3c 14.7.19 channel multiplexer register name: chmxn access type: read/write offset: 0x100 + n*0x004 reset value: 0x00000000 ? evmx: event multiplexer select input event / generator. ? smx: software event multiplexer 0: the software event is not selected. event / generator is selected by evmx. 1: the software event is selected. evmx is not considered. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------smx 76543210 - - evmx evmx smx channel input 0x00 0 evt0 0x01 0 evt1 0xm 0 evtm > trigout 0 none any 1 software event
250 32117b?avr-03/11 at32uc3c 14.7.20 event shaper register name: evsm access type: read/write offset: 0x200 + m*0x004 reset value: 0x00000000 ? evr: event rise 0: no event detection on rising edge. 1: event detection on rising edge. ? evf: event fall 0: no event detection on falling edge. 1: event detection on falling edge. ? igf: input glitch filter 0: input glitch filter is off. 1: input glitch filter is on. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - igf evf evr
251 32117b?avr-03/11 at32uc3c 14.8 module configuration the specific configuration for each pevc instance is listed in the following tables. the module bus clocks listed here are conn ected to the system bus clocks. refer to the power manager chapter for details. the busy0[21:16] field will a lways be read as 0x3f. the pevc routes events fr om event generato r to trigger an action in the event user. the follow- ing tables defines the corres ponding input event generator in evmx registers and if an event shaper is implemented for this generator. table 14-3. module configuration feature parameter pevc number of generators evin 34 number of event shapers evs 24 number of channels / users trigout 22 table 14-4. module clock name module name clock name description pevc clk_pevc hsb clock table 14-5. register reset values register reset value busy0 0x0000ffff version 0x00000100 pa r a m e t e r r e fe r t o table 14-3 table 14-6. pevc event numbers event number (evmx) event generator - event source event shaper [15:0] pad_evt[15:0] - change on input pins ye s 16 the generic clock gclk7 yes 17 the generic clock gclk8 yes 18 tc0 - a0 rising edge yes 19 tc0 - a1 rising edge yes 20 tc0 - a2 rising edge yes 21 tc0 - b0 rising edge yes 22 tc0 - b1 rising edge yes 23 tc0 - b2 rising edge yes 24 acifa0 - event 0 25 acifa0 - event 1
252 32117b?avr-03/11 at32uc3c the following tables defines the triggered action for each pevc channel. 26 acifa1 - event 0 27 acifa1 - event 1 28 ast - alarm event 0 29 ast - period event 0 30 pwm - compare match on event 0 31 pwm - compare match on event 1 32 qdec0 - compare match 33 qdec1 - compare match table 14-7. pevc channel channel number event user - triggered event 0 adcifa - sequencer 0 start of conversion 1 adcifa - sequencer 1 start of conversion 2 dacifb0 - start of conversion cha 3 dacifb0 - start of conversion chb 4 dacifb1 - start of conversion cha 5 dacifb1 - start of conversion chb 6 pdca - start of transfer channel 0 7 pdca - start of transfer channel 1 8 pwm - fault input 0 9 pwm - fault input 1 10 qdec0 - capture 11 qdec0 - toggle direction of counting 12 qdec0- trigger 13 qdec1 - capture 14 qdec1 - toggle direction of counting 15 qdec1- trigger 16 tc0 - input capture a0 17 tc0 - input capture a1 18 tc0 - input capture a2 19 tc0 - input capture b0 20 tc0 - input capture b1 21 tc0 - input capture b2 table 14-6. pevc event numbers event number (evmx) event generator - event source event shaper
253 32117b?avr-03/11 at32uc3c 15. flash controller (flashc) rev: 3.0.2.2 15.1 features ? controls flash block with dual read ports allowing staggered reads. ? supports 0 and 1 wait state bus access. ? allows interleaved burst reads for systems with one wait state, outputti ng one 32-bit word per clock cycle. ? 32-bit hsb interface for reads from flash array and writes to page buffer. ? 32-bit pb interface for issuing commands to and configuration of the controller. ? 16 lock bits, each protecting a region consisting of (total number of pages in the flash block / 16) pages. ? regions can be indi vidually protected or unprotected. ? additional protection of the boot loader pages. ? supports reads and writes of general-purpose nvm bits. ? supports reads and writes of additional nvm pages. ? supports device protection through a security bit. ? dedicated command for chip-erase, first erasing all on-chip volatile me mories before erasing flash and clearing security bit. ? 15.2 overview the flash controller (flashc) interfaces the on-chip flash memory with the 32-bit internal hsb bus. the controller manages the reading, writing, erasing, locking, and unlocking sequences. 15.3 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 15.3.1 power management if the cpu enters a slee p mode that disables clocks used by the flashc, the flashc will stop functioning and resume operation after the system wakes up from sleep mode. 15.3.2 clocks the flashc has two bus clocks connected: one high speed bus clock (clk_flashc_hsb) and one peripheral bus clock (clk_flashc_pb). these clocks are generated by the power manager. both clocks are enabled at reset, and can be disabled by writing to the power man- ager. the user has to ensure that clk_flashc_hsb is not turned off before reading the flash or writing the pagebuffer and that clk_flashc_pb is not turned off before accessing the flashc configuration and control registers. failing to do so may deadlock the bus. 15.3.3 interrupt the flashc interrupt request lines are connected to the interrupt controller. using the flashc interrupts requires the interrupt controller to be programmed first.
254 32117b?avr-03/11 at32uc3c 15.3.4 debug operation when an external debugger forces the cpu into debug mode, the flashc continues normal operation. if the flashc is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. 15.4 functional description 15.4.1 bus interfaces the flashc has two bus interfaces, one high-speed bus (hsb) interface for reads from the flash memory and writes to the page buffer, and one peripheral bus (pb) interface for issuing commands and reading status from the controller. 15.4.2 memory organization the flash memory is divided into a set of pages. a page is the basic unit addressed when pro- gramming the flash. a page consists of several words. the pages are grouped into 16 regions of equal size. each of these regions can be locked by a dedicated fuse bit, protecting it from acci- dental modification. ? p pages ( flash_p ) ?w bytes in each page and in the page buffer ( flash_w ) ? pw bytes in total ( flash_pw ) ? f general-purpose fuse bits ( flash_f ), used as region lock bits and for other device-specific purposes ? 1 security fuse bit ? 1 factory page ? 1 user page 15.4.3 user page the user page is an additional page, outside the regular flash array, that can be used to store various data, such as calibration data and serial numbers. this page is not erased by regular chip erase. the user page can only be written and erased by a special set of commands. read accesses to the user page are performed just as any other read accesses to the flash. the address map of the user page is given in figure 15-1 . 15.4.4 factory page the factory page is an additional page, outside th e regular flash array, that can be used to store various data, such as calibration data and serial numbers. this page is not erased by regular chip erase. read accesses to the factory page is performed just as any other read access to the flash. the address map of the factory page is given in figure 15-1 . 15.4.5 read operations the on-chip flash memory is typically used for storing instructions to be executed by the cpu. the cpu will address instructions using the hsb bus, and the flashc will access the flash memory and return the addressed 32-bit word. in systems where the hsb clock period is slower than the access time of the flash memory, the flashc can operate in 0 wait state mode, and output one 32-bit word on the bus per clock cycle. if the clock frequency allows, the user should use 0 wait state mode, because this gives the highest performance as no stall cycles are encountered.
255 32117b?avr-03/11 at32uc3c the flashc can also operate in systems where the hsb bus clock period is faster than the access speed of the flash memory. wait state support and a read granularity of 64 bits ensure efficiency in such systems. performance for systems with high clock frequency is increased since the flash internally is con- figured as two separate banks of 32 bits. each bank has its own read port. in 0ws mode, only one of the two flash read ports is accessed. the other flash read port is idle. in 1ws mode, both flash read ports are active. one read port reading the addressed word, and the other reading the next sequential word. the programmer can select the wait states required by writing to the fws field in the flash con- trol register (fcr). it is the responsibility of the prog rammer to select a nu mber of wait states compatible with the clock frequency and timing characteristics of the flash memory. in 0ws mode, no wait states are encountered on any flash read operations. in 1 ws mode, one stall cycle is encountered on the first access in a single or burst transfer. if the clock frequency allows, the user should use 0ws mode, because this gives the lowest power consumption for low-frequency systems as on ly one flash read port is read. using 1ws mode has a power/performance ratio approaching 0ws mode as the clock frequency approaches twice the max frequency of 0ws mode. using two flash read ports use twice the power, but also give twice the performance. the flash controller address space is displayed in figure 15-1 . the memory space between address pw and the user page is reserved, and reading addresses in this space returns an undefined result. the user page is permanently mapped to an offset of 0x0080 0000 from the start address of the flash memory. the factory page is permanently mapped to an offset of 0x0080 0200 from the start address of the flash memory. table 15-1. user page addresses memory type start address, byte sized size main array 0 pw bytes user 0x0080 0000 w bytes factory page 0x0080 0200 w bytes
256 32117b?avr-03/11 at32uc3c figure 15-1. memory map for the flash memories2 15.4.6 high speed read mode the flash provides a high speed read mode, offering slightly higher flash read speed at the cost of higher power consumption. two dedicated commands, high speed read mode enable (hsen) and high speed read mode disable (hsdis) control the speed mode. the high speed mode (hsmode) in flash status register (fsr) shows which mode the flash is in. after reset, the high speed mode is disabled, and must be manually enabled if the user wants to. refer to the electrical characteristics chapter at the end of this datasheet for details on the max- imum clock frequencies in normal and high speed read mode. 0 pw 0x0080 0200 reserved flash data array factory page user page flash with extra pages 0x0080 0000 all addresses are byte addresses flash base address offset from base address
257 32117b?avr-03/11 at32uc3c figure 15-2. high speed mode 15.4.7 quick page read a dedicated command, quick page read (qpr), is provided to read all words in an addressed page. all bits in all words in this page are and?e d together, returning a 1-bi t result. this result is placed in the quick page read result (qprr) bi t in flash status register (fsr). the qpr command is useful to check that a page is in an erased state. the qpr instruction is much faster than performing the erased-page check using a regular software subroutine. 15.4.8 page buffer operations the flash memory has a write and erase granularity of one page; data are written and erased in chunks of one page. when programming a page, the user must first write the new data into the page buffer. the contents of the entire page buffer is copied into the desired page in flash memory when the user issues the write page command, see section ?15.5.1? on page 259. in order to program data into flash page y, write the desired data to locations y0 to 63 in the reg- ular flash memory map. writi ng to an address a in the flash memory map will not update the flash memory, but will inst ead update location a% 64 in the page buffer. th e pagen field in the flash command (fcmd) register will at the same time be up dated with the value a/64. frequency frequency limit for 0 wait state operation no r m al high speed mode 1 wait state 0 wait state
258 32117b?avr-03/11 at32uc3c figure 15-3. mapping from page buffer to flash the page buffer is word-addressable and should only be written with aligned word transfers, never with byte or halfword transfers. the page buffer can not be read. the page buffer is also used for writes to the user page. page buffer write operations are performed with 4 wait states. any accesses attempted to the flashc on the hsb bus during these cycles will be automatically stalled. writing to the page buffer can only change page buffer bits from one to zero, i.e. writing 0xaaaaaaaa to a page buffer loca tion that has the value 0x 00000000 will not change the page buffer value. the only way to change a bit from zero to one is to erase the entire page buffer with the clear page buffer command. the page buffer is not automatically reset after a page write. the programmer should do this manually by issuing the clear page buffer flas h command. this can be done after a page write, or before the page buffer is loaded with data to be stored to the flash page. 15.4.9 writing words to a page that is not completely erased this can be used for eeprom emulation, i.e. writes with granularity of one word instead of an entire page. only words that are in an comp letely erased state (0xffffffff) can be changed. the procedure is as follows: 35 34 33 32 39 38 37 36 43 42 41 40 47 46 45 44 51 50 49 48 55 54 53 52 59 58 57 56 63 62 61 60 page buffer 32-bit data flash all locations are word locations 3 2 1 0 7 6 5 4 11 10 9 8 15 14 13 12 19 18 17 16 23 22 21 20 27 26 25 24 31 30 29 28 x35 x34 x33 x32 x39 x38 x37 x36 x43 x42 x41 x40 x47 x46 x45 x44 x51 x50 x49 x48 x55 x54 x53 x52 x59 x58 x57 x56 x63 x62 x61 x60 x3 x2 x1 x0 x7 x6 x5 x4 x11 x10 x9 x8 x15 x14 x13 x12 x19 x18 x17 x16 x23 x22 x21 x20 x27 x26 x25 x24 x31 x30 x29 x28 page x y35 y34 y33 y32 y39 y38 y37 y36 y43 y42 y41 y40 y47 y46 y45 y44 y51 y50 y49 y48 y55 y54 y53 y52 y59 y58 y57 y56 y63 y62 y61 y60 y3 y2 y1 y0 y7 y6 y5 y4 y11 y10 y9 y8 y15 y14 y13 y12 y19 y18 y17 y16 y23 y22 y21 y20 y27 y26 y25 y24 y31 y30 y29 y28 page y
259 32117b?avr-03/11 at32uc3c 1. clear page buffer 2. write to the page buffer the result of the logical bitwise and operation between the contents of the flash page and the new data to write. only bits that were in an erased state can be changed from the original page. 3. write page. 15.5 flash commands the flashc offers a command set to manage programming of the flash memory, locking and unlocking of regions, and full flash erasing. see section 15.8.2 for a complete list of commands. to run a command, the field cmd of the flash command register (fcmd) has to be written with the command number. as soon as the fcmd regi ster is written, the frdy bit is automati- cally cleared. once the current command is co mplete, the frdy bit is automatically set. if an interrupt has been enabled by writing a one to fcr.frdy, the interrupt request line of the flash controller is activated. all fl ash commands except for quick pa ge read (qpr) will generate an interrupt request upon completion if frdy is written to one. any hsb bus transfers attempting to read flash memory when the flashc is busy executing a flash command will be stalled, a nd allowed to continue when th e flash command is complete. after a command has been written to fcmd, the programming algorithm should wait until the command has been executed before attempting to read instructions or data from the flash or writing to the page buffer, as the flash will be busy. the waiting can be pe rformed either by poll- ing the flash status register (fsr) or by waiting for the flash ready interrupt. the command written to fcmd is initiated on the first clock cycle where the hsb bus interface in flashc is idle. the user must make sure that the access pattern to the flashc hsb interface contains an idle cycle so that the command is allowed to start. make sure that no bus masters such as dma controllers are performing endless burst transfers from the flash. also, make sure that the cpu does not perform endless burst transfers from flash. this is done by letting the cpu enter sleep mode after writing to fcmd, or by polling fsr for command completion. this polling will result in an access patt ern with idle hsb cycles. all the commands are protected by the same keyword, which has to be written in the eight high- est bits of the fcmd register. writing fcmd wi th data that does not contain the correct key and/or with an invalid command has no effect on the flash memory; however, the proge bit is set in the flash status register (fsr). this bit is automatically cleared by a read access to the fsr register. writing a command to fcmd while another command is being executed has no effect on the flash memory; however, the proge bit is set in the flash status register (fsr). this bit is automatically cleared by a read access to the fsr register. if the current command writes or erases a page in a locked region, or a page protected by the bootprot fuses, the command has no effect on the flash memory; however, the locke bit is set in the fsr register. this bit is automatically cleared by a read access to the fsr register. 15.5.1 write/erase page operation flash technology requires that an erase must be done before programming. the entire flash can be erased by an erase all command. alternativ ely, pages can be individually erased by the erase page command. the user page can be written and erased usin g the mechanisms descr ibed in this chapter.
260 32117b?avr-03/11 at32uc3c after programming, the page can be locked to pr event miscellaneous write or erase sequences. locking is performed on a per-region basis, so locking a region locks all pages inside the region. additional protection is provided for the lowermost address space of the flash. this address space is allocated for the boot loader, and is protected both by the lock bit(s) corresponding to this address space, and the bootprot[2:0] fuses. data to be written are stored in an internal buffer called page buffer. the page buffer contains w words. the page buffer wraps around within the internal memory area address space and appears to be repeated by the number of pages in it. writing of 8-bit and 16-bit data to the page buffer is not allowed and may lead to unpredictable data corruption. data must be written to the page buffer before the programming command is written to the flash command register fcmd. the sequence is as follows: ? reset the page buffer with the clear page buffer command. ? fill the page buffer with the desired content s as described in section 15.4.8 on page 257 . ? programming starts as soon as the programming key and the programming command are written to the flash command register. the pagen field in the flash command register (fcmd) must contain the address of the page to write. pagen is automatically updated when writing to the page buffer, but can also be written to directly. the frdy bit in the flash status register (fsr) is automatically cleared when the page write operation starts. ? when programming is completed, the bit frdy in the flash status register (fsr) is set. if an interrupt was enabled by writing a one to fcr.frdy, the interrupt line of the flash controller is set. two errors can be detected in the fsr register after a programming sequence: ? programming error: a bad keyword and/or an invalid command have been written in the fcmd register. ? lock error: can have two different causes: ? the page to be programmed belongs to a locked region. a command must be executed to unlock the corresponding region before programming can start. ? a bus master without secure status attempted to program a page requiring secure privileges. 15.5.2 erase all operation the entire memory is erased if the erase all command (ea) is written to the flash command register (fcmd). erase all erases all bits in the flash array. the user page is not erased. all flash memory locations, the general-purpose fuse bi ts, and the security bit are erased (reset to 0xff) after an erase all. the ea command also ensures that all volatile me mories, such as register file and rams, are erased before the security bit is erased. erase all operation is allowed only if no regions are locked, and the bootprot fuses are con- figured with a bootprot region size of 0. thus, if at least one region is locked, the bit locke in fsr is set and the command is cancelled. if the bit locke has been written to 1 in fcr, the interrupt request line is set. when the command is complete, the frdy bit in th e flash status register (fsr) is set. if an interrupt has been enabled by writing a one to fcr.frdy, the interrupt line of the flash control- ler is set. two errors can be detected in the fsr register after issuing the command:
261 32117b?avr-03/11 at32uc3c ? programming error: a bad keyword and/or an invalid command have been written in the fcmd register. ? lock error: at least one lock region is protected, or bootprot is different from 0. the erase command has been aborted and no page has been erased. a ?unlock region containing given page? (up) command must be executed to unlock any locked regions. 15.5.3 region lock bits the flash memory has p pages, and these pages are grouped into 16 lock regions, each region containing p /16 pages. each region has a dedicated lock bit preventing writing and erasing pages in the region. after production, the device may have some regions locked. these locked regions are reserved for a boot or default applic ation. locked regions can be unlocked to be erased and then programmed with another application or other data. to lock or unlock a region, the commands lock region containing page (lp) and unlock region containing page (up) are provided. writing one of these commands, together with the number of the page whose region should be locked/unlocked, performs the desired operation. one error can be detected in the fsr register after issuing the command: ? programming error: a bad keyword and/or an invalid command have been written in the fcmd register. the lock bits are implemented using the lowest 16 general-purpose fuse bits. this means that lock bits can also be set/cleared using the commands for writing/erasing general-purpose fuse bits, see section 15.6 . the general-purpose bit being in an erased (1) state means that the region is unlocked. the lowermost pages in the flash can additionally be protected by the bootprot fuses, see section 15.6 . 15.6 general-purpose fuse bits the flash memory has a number of general-purpose fuse bits that the application programmer can use freely. the fuse bits can be writ ten and erased using dedicated commands, and read
262 32117b?avr-03/11 at32uc3c through a dedicated peripheral bus address. some of the general-purpose fuse bits are reserved for special purposes, and shou ld not be used for other functions.: table 15-2. general-purpose fuses with special functions general- purpose fuse number name usage 15:0 lock region lock bits. 16 epfl external privileged fetch lock. used to prevent the cpu from fetching instructions from external memories when in privileged mode. this bit can only be changed when the security bit is cleared. the address range corresponding to external memories is device-specific, and not known to the flash controller. this fuse bit is simply routed out of the cpu or bus system, the flash controller does not treat this fuse in any special way, except that it can not be altered when the security bit is set. if the security bit is set, only an external jtag chip erase can clear epfl. no internal commands can alter epfl if the security bit is set. when the fuse is erased (i.e. "1"), the cpu can execute instructions fetched from external memories. when the fuse is programmed (i.e. "0"), instructions can not be executed from external memories. this fuse has no effect in de vices with no external memory interface (ebi). 19:17 bootprot used to select one of eight different bootloader sizes. pages included in the bootloader area can not be erased or programmed except by a jtag chip erase. bootprot can only be changed when the security bit is cleared. if the security bit is set, only an external jtag chip erase can clear bootprot, and thereby allow the pages protected by bootprot to be programmed. no internal commands can alter bootprot or the pages protected by bootprot if the security bit is set. 21:20 secure used to configure secure state and secure state debug capabilities. refer to the avr32 architecture manual and the avr32uc technical reference manual for more details. 22 uprot if programmed (i.e. ?1?), the jtag user protection feature is enabled. if this fuse is programmed some hsb addresses will be accessible by jtag access even if the flash security fuse is programmed. refer to the jtag documentation for more information on this functionality. this bit can only be changed when the security bit is cleared.
263 32117b?avr-03/11 at32uc3c the bootprot fuses protects the following address space for the boot loader: the secure fuses have the following functionality: to erase or write a general-purpose fuse bit, the commands write general-purpose fuse bit (wgpb) and erase general-purpose fuse bit (e gpb) are provided. writing one of these com- mands, together with the number of the fuse to write/erase, performs the desired operation. an entire general-purpose fuse byte can be written at a time by using the program gp fuse byte (pgpfb) instruction. a pgpfb to gp fuse byte 2 is not allowed if the flash is locked by the security bit. the pfb command is issued with a parameter in the pagen field: ? pagen[2:0] - byte to write ? pagen[10:3] - fuse value to write all general-purpose fuses can be erased by the erase all general-purpose fuses (eagp) com- mand. an eagp command is not allowed if the flash is locked by the security bit. two errors can be detected in the fsr register after issuing these commands: ? programming error: a bad keyword and/or an invalid command have been written in the fcmd register. ? lock error: ? a write or erase of the bootprot or epfl or uprot fuse bits was attempted while the flash is locked by the security bit. ? a write or erase of the secure fuse bi ts was attempted when secure mode was enabled. table 15-3. boot loader area specified by bootprot bootprot pages protected by bootprot size of protected memory 7none 0 60-1 1kbyte 50-3 2kbyte 40-7 4kbyte 3 0-15 8kbyte 2 0-31 16kbyte 1 0-63 32kbyte 0 0-127 64kbyte table 15-4. secure state configuration secure functionality 00 secure state disabled 01 secure enabled, secure state debug enabled 10 secure enabled, secure state debug disabled 11 secure state disabled
264 32117b?avr-03/11 at32uc3c the lock bits are implemented using the lowest 16 general-purpose fuse bits. this means that the 16 lowest general-purpose fuse bits can also be written/erased using the commands for locking/unlocking regions, see section 15.5.3 . 15.7 security bit the security bit allows the entire chip to be locked from external jtag or other debug access for code security. the security bit can be written by a dedicated command, set security bit (ssb). once set, the only way to clear the security bit is through the jtag chip erase command. once the security bit is set, the following flash controller commands will be unavailable and return a lock error if attempted: ? write general-purpose fuse bit (w gpb) to bootprot or epfl fuses ? erase general-purpose fuse bit (egpb) to bootprot or epfl fuses ? program general-purpose fuse byte (pgpfb) of fuse byte 2 ? erase all general-purpose fuses (eagpf) one error can be detected in the fsr register after issuing the command: ? programming error: a bad keyword and/or an invalid command have been written in the fcmd register.
265 32117b?avr-03/11 at32uc3c 15.8 user interface note: 1. the value of the lock bits is dependent of their programmed state. all other bits in fsr are 0. all bits in fgpfr are d epen- dent on the programmed state of the fuses they map to. an y bits in these registers not mapped to a fuse read 0. 2. the reset values for these registers are device specific. plea se refer to the module configuration section at the end of this chapter. table 15-5. flashc register memory map offset register register name access reset 0x0 flash control register fcr read/write 0x00000000 0x4 flash command register fcmd read/write 0x00000000 0x8 flash status register fsr read/write 0 (1) 0xc flash parameter register pr read-only 0 (2) 0x10 flash version register vr read-only 0 (2) 0x14 flash general purpose fuse register hi fgpfrhi read-only na (1) 0x18 flash general purpose fuse register lo fgpfrlo read-only na (1)
266 32117b?avr-03/11 at32uc3c 15.8.1 flash control register name: fcr access type: read/write offset :0x00 reset value: 0x00000000 ? fws: flash wait state 0: the flash is read with 0 wait states. 1: the flash is read with 1 wait state. ? proge: programming error interrupt enable 0: programming error does not generate an interrupt. 1: programming error generates an interrupt. ? locke: lock error interrupt enable 0: lock error does not generate an interrupt. 1: lock error generates an interrupt. ? frdy: flash ready interrupt enable 0: flash ready does not generate an interrupt. 1: flash ready generates an interrupt. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - fws - - proge locke - frdy
267 32117b?avr-03/11 at32uc3c 15.8.2 flash command register name: fcmd access type: read/write offset :0x04 reset value: 0x00000000 the fcmd can not be written if the flash is in the process of performing a flash command. doing so will cause the fcr write to be ig nored, and the proge bit to be set. ? key: write protection key this field should be written with the value 0xa5 to enable the command defined by the bits of t he register. if the field is wri tten with a different value, the write is not performed and no action is started. this field always reads as 0. ?pagen: page number the pagen field is used to address a page or fuse bit for certai n operations. in order to simplify programming, the pagen field is automatically updated every time the page buffer is written to. for every page buffer write, the pagen field is updated with the page number of the address being written to. hardware automatically masks writes to the pagen field so that only bits representing valid page numbers can be writt en, all other bits in pagen are always 0. as an example, in a flash with 1024 pages (page 0 - page 1023), bits 15:10 will always be 0. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 pagen [15:8] 15 14 13 12 11 10 9 8 pagen [7:0] 76543210 -- cmd table 15-6. semantic of pagen field in different commands command pagen description no operation not used write page the number of the page to write clear page buffer not used lock region containing given page page number whose region should be locked unlock region containing given page page number whose region should be unlocked erase all not used write general-purpose fuse bit gpfuse # erase general-purpose fuse bit gpfuse # set security bit not used
268 32117b?avr-03/11 at32uc3c ? cmd: command this field defines the flash command. issuing any unused co mmand will cause the programming error bit to be set, and the corresponding interrupt to be requested if the proge bit in fcr is set. program gp fuse byte writed ata[7:0], byteaddress[2:0] erase all gp fuses not used quick page read page number write user page not used erase user page not used quick page read user page not used high speed mode enable not used high speed mode disable not used table 15-7. set of commands command value mnemonic no operation 0 nop write page 1 wp erase page 2 ep clear page buffer 3 cpb lock region containing given page 4 lp unlock region containing given page 5 up erase all 6 ea write general-purpose fuse bit 7 wgpb erase general-purpose fuse bit 8 egpb set security bit 9 ssb program gp fuse byte 10 pgpfb erase all gpfuses 11 eagpf quick page read 12 qpr write user page 13 wup erase user page 14 eup quick page read user page 15 qprup high speed mode enable 16 hsen high speed mode disable 17 hsdis table 15-6. semantic of pagen field in different commands command pagen description
269 32117b?avr-03/11 at32uc3c 15.8.3 flash status register name: fsr access type: read-only offset :0x08 reset value: 0x00000000 ? lockx: lock region x lock status 0: the corresponding lock region is not locked. 1: the corresponding lock region is locked. ? hsmode: high-speed mode 0: high-speed mode disabled. 1: high-speed mode enabled. ? qprr: quick page read result 0: the result is zero, i.e. the page is not erased. 1: the result is one, i.e. the page is erased. ? security: security bit status 0: the security bit is inactive. 1: the security bit is active. ? proge: programming error status automatically cleared when fsr is read. 0: no invalid commands and no bad keywords were written in the flash command register fcmd. 1: an invalid command and/or a bad keyword was/we re written in the flash command register fcmd. ? locke: lock error status automatically cleared when fsr is read. 0: no programming of at least one locked lock region has happened since the last read of fsr. 1: programming of at least one locked lock region has happened since the last read of fsr. ? frdy: flash ready status 0: the flash controller is busy and the application must wait before running a new command. 1: the flash controller is ready to run a new command. 31 30 29 28 27 26 25 24 lock15 lock14 lock13 lock12 lock11 lock10 lock9 lock8 23 22 21 20 19 18 17 16 lock7 lock6 lock5 lock4 lock3 lock2 lock1 lock0 15 14 13 12 11 10 9 8 -------- 76543210 - hsmode qprr security proge locke - frdy
270 32117b?avr-03/11 at32uc3c 15.8.4 parameter register name: pr access type: read-only offset :0x0c reset value: 0x00000000(*) ? fsz: flash size the size of the flash. not all device families will provide all flash sizes indicated in the table. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----- psz 76543210 ---- fsz table 15-8. flash size fszflash sizefszflash size 0 4 kbyte 8 192 kbyte 1 8 kbyte 9 256 kbyte 2 16 kbyte 10 384 kbyte 3 32 kbyte 11 512 kbyte 4 48 kbyte 12 768 kbyte 5 64 kbyte 13 1024 kbyte 6 96 kbyte 14 2048 kbyte 7 128 kbyte 15 reserved
271 32117b?avr-03/11 at32uc3c ? psz: page size the size of a flash page. table 15-9. flash page size psz page size 032 words 164 words 2128 words 3256 words 4512 words 5 1024 words 6 2048 words 7 4096 words
272 32117b?avr-03/11 at32uc3c 15.8.5 version register name: vr access type: read-only offset :0x10 reset value: 0x00000000(*) ? variant: variant number reserved. no functi onality associated. ? version: version number version number of the module . no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 ---- version[11:8]- 76543210 version[7:0]
273 32117b?avr-03/11 at32uc3c 15.8.6 flash general purpose fuse register high name: fgpfrhi access type: read-only offset :0x14 reset value: na(*) this register is only used in syst ems with more t han 32 gp fuses. ? gpfxx: general purpose fuse xx 0: the fuse has a written/programmed state. 1: the fuse has an erased state. 31 30 29 28 27 26 25 24 gpf63 gpf62 gpf61 gpf60 gpf59 gpf58 gpf57 gpf56 23 22 21 20 19 18 17 16 gpf55 gpf54 gpf53 gpf52 gpf51 gpf50 gpf49 gpf48 15 14 13 12 11 10 9 8 gpf47 gpf46 gpf45 gpf44 gpf43 gpf42 gpf41 gpf40 76543210 gpf39 gpf38 gpf37 gpf36 gpf35 gpf34 gpf33 gpf32
274 32117b?avr-03/11 at32uc3c 15.8.7 flash general purpose fuse register low name: fgpfrlo access type: read-only offset :0x18 reset value: na(*) ? gpfxx: general purpose fuse xx 0: the fuse has a written/programmed state. 1: the fuse has an erased state. 31 30 29 28 27 26 25 24 gpf31 gpf30 gpf29 gpf28 gpf27 gpf26 gpf25 gpf24 23 22 21 20 19 18 17 16 gpf23 gpf22 gpf21 gpf20 gpf19 gpf18 gpf17 gpf16 15 14 13 12 11 10 9 8 gpf15 gpf14 gpf13 gpf12 gpf11 gpf10 gpf09 gpf08 76543210 gpf07 gpf06 gpf05 gpf04 gpf03 gpf02 gpf01 gpf00
275 32117b?avr-03/11 at32uc3c 15.9 fuses settings the flash block contains 32 general purpose fuses. these 32 fuses can be found in the flash general purpose fuse register low. some of these fuses have defined meanings outside the flash controller and are described in this section. in addition to the general purpose fuses parts of the flash, user page can have a defined mean- ing outside the flash controller and are described in this section. note that after writing the user page, values will not be propagated to other modules internally on the device. other modules will load these values after resetting the chip. the general purpose fuses are erased by a jtag or awire chip erase. 15.9.1 flash general purpose fuse register (fgpfrlo) ? bod33en: 3.3v brown out detector enable ? boden: 1.8v brown out detector enable table 15-10. fgpfr register description 31 30 29 28 27 26 25 24 bod33en boden bodhyst bodlevel[3:1] 23 22 21 20 19 18 17 16 bodlevel[0] uprot secure bootprot epfl 15 14 13 12 11 10 9 8 lock[15:8] 7 6543210 lock[7:0] table 15-11. bod33en field description bod33en description 0x0 bod33 disabled 0x1 bod33 enabled, bod33 reset enabled 0x2 bod33 enabled, bod33 reset disabled 0x3 bod33 disabled table 15-12. boden field description boden description 0x0 bod18 disabled 0x1 bod18 enabled, bod18 reset enabled 0x2 bod18 enabled, bod18 reset disabled 0x3 bod18 disabled
276 32117b?avr-03/11 at32uc3c ? bodhyst: 1.8v brown out detector hysteresis 0: the bod18 hysteresis is disabled. 1: the bod18 hysteresis is enabled. ? bodlevel: 1.8v brown out detector trigger level this controls the voltage tr igger level for the bod18. when the flash fuse calibration is done (scif.bod.fcd is set): scif.bod.level is loaded to 0x28 if the bodlevel fuses are greater than 0xa. scif.bod.level is loaded to (bodlevel x 4) if the bodlevel fuses are lower or equal to 0xa. refer to see ?electrical characteristics? on page 1249. ? uprot, secure, bootprot, epfl, lock these are flash controller fuses an d are described in the flashc section. 15.9.2 default fuse value the devices are shipped with the fgpfrlo register value: 0xf877ffff: ? bod33en fuses set to 11. bod33 is disabled. ? boden fuses set to 11. bod18 is disabled. ? bodhyst fuse set to 1. the bod18 hysteresis is enabled. ? bodlevel fuses set to 0000. this is the minimum voltage level for bod18. ? uprot fuse set to 1 ? secure fuses set to 11 ? bootprot fuses set to 011. the bootloader protected size is 8 kbytes. ? epfl fuse set to 1. external privileged fetch is not locked. ? lock fuses set to 1111111111111111. no region locked. see also the at32uc3c bootloader user guide document. after the jtag or awire chip erase command, the fgpfrlo register value is 0xffffffff.
277 32117b?avr-03/11 at32uc3c 15.9.3 fuses in user page (address 0x80800000) 15.9.3.1 first word (address 0x80800000) ? ss_adrr: size of the cpu ram co ntrolled by the secure state the section of the cpu ram controlled by the secure stat e is from address 0x00000000 to address (ss_adrr << 10). ? ss_adrf: size of the flash controlled by the secure state the section of the flash controlled by the secure stat e is from address 0x80000000 to address (ss_adrf << 10). ? wdtdisrv: watchdog timer auto disable at startup 0: the wdt is automatically enabled at startup, the wdtauto fuse of the wdt is set. 1: the wdt is not automatically e nabled at startup, the wdtauto fuse of the watchdog timer is not set. please refer to the wdt chapter for detail about time- out settings when the wdt is automatically enabled. the devices are shipped with the user page erased (all bits 1). 15.9.4 bootloader configuration the usb/usart bootloader uses two words in the flash user page to store its configuration: ? configuration word 1 at address 0x808001fc is read first at boot time to know if it should start the isp process unconditionally and whether it should use the configuration word 2 where further configuration is stored. ? configuration word 2 at address 0x808001f8 stores the i/o conditions that determine which of the usb dfu isp and the application to start at the end of the boot process. please refer to the bootloader documentation for more information. table 15-13. user page fu se description 31 30 29 28 27 26 25 24 wdtdisrv ss_adrr[14:8] 23 22 21 20 19 18 17 16 ss_adrr[7:0] 15 14 13 12 11 10 9 8 ss_adrf[15:8] 76543210 ss_adrf[7:0]
278 32117b?avr-03/11 at32uc3c 15.10 calibration settings some analog blocks require to be calibrated. the recommended calibration settings are written in the factory page. the base address of the factory page is 0x80800200. table 15-14. calibration register map offset register 0x0000 oscillator calibration 0x0004 adc core calibration 0x0008 adc s/h calibration 0x000c dac0a channel calibration 0x0010 dac0b channel calibration 0x0014 dac1a channel calibration 0x0018 dac1b channel calibration
279 32117b?avr-03/11 at32uc3c 15.10.0.1 oscillator calib ration (offset 0x0000) ? rc1m_calib_5v: calibration of rc8m operating at 1mhz and at 5v this calibration should be used when the rc8m is used at a frequency of 1 mhz and when the voltage of the vddin_5 pin is within [4.5v:5.5v]. this value should be writte n to rccr8.calib field of the scif module. ? rc8m_calib_5v: calibration of rc8m operating at 8mhz and at 5v this calibration should be used when the rc8m is used at a frequency of 8 mhz and when the voltage of the vddin_5 pin is within [4.5v:5.5v]. this value should be written to rccr8.calib. ? rc1m_calib: calibration of rc8m operating at 1mhz and at 3.3v this calibration should be used when the rc8m is used at a frequency of 1 mhz and when the voltage of the vddin_5 pin is within [3.0v:3.6v]. this value should be written to rccr8.calib. ? rc8m_calib: calibration of rc8m operating at 8mhz and at 3.3v this calibration should be used when the rc8m is used at a frequency of 8 mhz and when the voltage of the vddin_5 pin is within [3.0v:3.6v]. this value is automatically loaded in rccr8.calib at power-up. table 15-15. oscillator calibration 31 30 29 28 27 26 25 24 rc1m_calib_5v[7:0] 23 22 21 20 19 18 17 16 rc8m_calib_5v[7:0] 15 14 13 12 11 10 9 8 rc1m_calib[7:0] 76543210 rc8m_calib[7:0]
280 32117b?avr-03/11 at32uc3c 15.10.0.2 adc core calibration (offset 0x0004) ? adc_ocal: offset calibration of the adc core this value should be written to the adccal.ocal field of the adcifa module. ? adc_gcal: gain calibra tion of the adc core this value should be written to the adccal.gcal field of the adcifa module. table 15-16. adc core calibration 31 30 29 28 27 26 25 24 -- adc_ocal[5:0] 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 adc_gcal[14:8] 76543210 adc_gcal[7:0]
281 32117b?avr-03/11 at32uc3c 15.10.0.3 adc s/h calibration (offset 0x0008) ? adc_gain1: gain calibration of the adc s/h1 this value should be written to the s hcal.gain1 field of the adcifa module. ? adc_gain0: gain calibration of the adc s/h0 this value should be written to the s hcal.gain0 field of the adcifa module. table 15-17. adc s/h calibration 31 30 29 28 27 26 25 24 ------adc_gain1[9:8] 23 22 21 20 19 18 17 16 adc_gain1[7:0] 15 14 13 12 11 10 9 8 ------adc_gain0[9:8] 76543210 adc_gain0[7:0]
282 32117b?avr-03/11 at32uc3c 15.10.0.4 dac0 channel calibration (offset 0x000c (dac0 channel a), 0x0010 (dac0 channel b)), ? dac_gcal: gain calibration of the dac channel this value should be written to the goc.gcr field of the dacifb0 module. ? dac_ocal: offset calibration of the dac channel this value should be written to goc.ocr field of the dacifb0 module. table 15-18. dac0a and dac0b channel calibration 31 30 29 28 27 26 25 24 -------dac_gcal[8] 23 22 21 20 19 18 17 16 dac_gcal[7:0] 15 14 13 12 11 10 9 8 -------dac_ocal[8] 7654321 0 dac_ocal[7:0]
283 32117b?avr-03/11 at32uc3c 15.10.0.5 dac1 channel calibration (offset 0x0014 (dac1 channel a), 0x0018 (dac1 channel b)), ? dac_gcal: gain calibration of the dac channel this value should be written to the goc.gcr field of the dacifb1 module. ? dac_ocal: offset calibration of the dac channel this value should be written to goc.ocr field of the dacifb1 module. table 15-19. dac1a and dac1b channel calibration 31 30 29 28 27 26 25 24 -------dac_gcal[8] 23 22 21 20 19 18 17 16 dac_gcal1[7:0] 15 14 13 12 11 10 9 8 -------dac_ocal[8] 7654321 0 dac_ocal[7:0]
284 32117b?avr-03/11 at32uc3c 15.11 serial number each device has a unique 120 bits serial number readable from address 0x80800284 to 0x80800292. 15.12 module configuration the specific configuration for each flashc inst ance is listed in the following tables. the mod- ule bus clocks listed here are connected to the system bus clocks. plea se refer to the power manager chapter for details. table 15-20. module configuration flash size number of pages page size at32uc3c0512c at32uc3c1512c at32uc3c2512c 512kbytes 1024 128 words at32uc3c0256c at32uc3c1256c at32uc3c2256c 256kbytes 512 128 words at32uc3c0128c at32uc3c1128c at32uc3c2128c 128kbytes 256 128 words at32uc3c064c at32uc3c164c at32uc3c264c 64kbytes 128 128 words table 15-21. module clock name module name clock name description flashc clk_flashc_hsb hsb clock clk_flashc_pb peripheral bus clock from the pbb clock domain table 15-22. register reset values register reset value pr refer to table 15-20 vr 0x00000302
285 32117b?avr-03/11 at32uc3c 16. hsb bus matrix (hmatrixb) rev: 1.3.0.3 16.1 features ? user interface on peripheral bus ? configurable number of masters (up to 16) ? configurable number of slaves (up to 16) ? one decoder for each master ? programmable arbitration for each slave ? round-robin ? fixed priority ? programmable default master for each slave ? no default master ? last accessed default master ? fixed default master ? one cycle latency for the first access of a burst ? zero cycle latency for default master ? one special function register for each slave (not dedicated) 16.2 overview the bus matrix implements a multi-layer bus structure, that enables parallel access paths between multiple high speed bus (hsb) masters and slaves in a system, thus increasing the overall bandwidth. the bus matrix interconnects up to 16 hsb masters to up to 16 hsb slaves. the normal latency to connect a master to a slave is one cycle except for the default master of the accessed slave which is connected directly (zero cycle latency). the bus matrix provides 16 special function registers (sfr) that allow the bus matrix to support application specific features. 16.3 product dependencies in order to configure this module by accessing the user registers, other parts of the system must be configured correctly, as described below. 16.3.1 clocks the clock for the hmatrix bus interface (clk_hmatrix) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. 16.4 functional description 16.4.1 special bus granting mechanism the bus matrix provides some speculative bus granting techniques in order to anticipate access requests from some masters. this mechanism reduc es latency at first access of a burst or single transfer. this bus granting mechanism sets a different default master for every slave. at the end of the current access, if no other re quest is pending, the slave remains connected to its associated default master. a slave can be as sociated with three kinds of default masters: no default master, last access master, and fixed default master.
286 32117b?avr-03/11 at32uc3c to change from one kind of default master to another, the bus matrix user interface provides the slave configuration registers, one for each slave, that set a default master for each slave. the slave configuration register contains two fields: defmstr_type and fixed_defmstr. the 2-bit defmstr_type field selects the default mast er type (no default, last access master, fixed default master), whereas the 4-bit fixed_defmstr field selects a fixed default master pro- vided that defmstr_type is set to fixed default master. please refer to the bus matrix user interface description. 16.4.1.1 no default master at the end of the current access, if no other request is pending, the slave is disconnected from all masters. no default ma ster suits low-power mode. 16.4.1.2 last access master at the end of the current access, if no other re quest is pending, the slave remains connected to the last master that performed an access request. 16.4.1.3 fixed default master at the end of the current access, if no other r equest is pending, the slave connects to its fixed default master. unlike last access master, the fixed master does not change unless the user modifies it by a software action (field fixed_defmstr of the related scfg). 16.4.2 arbitration the bus matrix provides an arbitration mechanism that reduces latency when conflict cases occur, i.e. when two or more masters try to access the same slave at the same time. one arbiter per hsb slave is provided, thus ar bitrating each slave differently. the bus matrix provides the user with the possibility of choosing between 2 arbitration types for each slave: 1. round-robin arbitration (default) 2. fixed priority arbitration this is selected by the arbt field in the slave configuration registers (scfg). each algorithm may be complemented by selecting a default master configuration for each slave. when a re-arbitration must be done, specific conditions apply. this is described in ?arbitration rules? . 16.4.2.1 arbitration rules each arbiter has the ability to arbitrate between two or more different master requests. in order to avoid burst breaking and also to provide the maximum throughput for slave interfaces, arbitra- tion may only take place during the following cycles: 1. idle cycles: when a slave is not connected to any master or is connected to a master which is not currently accessing it. 2. single cycles: when a slave is currently doing a single access. 3. end of burst cycles: when the current cycle is the last cycle of a burst transfer. for defined length burst, predicted end of burst matches the size of the transfer but is man- aged differently for undefined length burst. this is described below. 4. slot cycle limit: when the slot cycle counte r has reached the limit value indicating that the current master access is too long and must be broken. this is described below.
287 32117b?avr-03/11 at32uc3c ? undefined length burst arbitration in order to avoid long slave handling during unde fined length bursts (incr), the bus matrix pro- vides specific logic in order to re-arbitrate before the end of the incr transfer. a predicted end of burst is used as a defined length burst transfer and can be selected among the following five possibilities: 1. infinite: no predicted end of burst is gen erated and therefore i ncr burst transfer will never be broken. 2. one beat bursts: predicted end of burst is generated at each single transfer inside the incp transfer. 3. four beat bursts: predicted end of burst is generated at the end of each four beat boundary inside incr transfer. 4. eight beat bursts: predicted end of burst is generated at the end of each eight beat boundary inside incr transfer. 5. sixteen beat bursts: predicted end of burst is generated at the end of each sixteen beat boundary inside incr transfer. this selection can be done through the ulbt field in the master configuration registers (mcfg). ? slot cycle limit arbitration the bus matrix contains specific logic to break long accesses, such as very long bursts on a very slow slave (e.g., an external low speed memory). at the beginning of the burst access, a counter is loaded with the value previously written in the slot_cycle field of the related slave configuration register (scfg) and decreased at each clock cycle. when the counter reaches zero, the arbiter has the ability to re-arbitrate at the end of the current byte, halfword, or word transfer. 16.4.2.2 round-robin arbitration this algorithm allows the bus matrix arbiters to dispatch the requests from different masters to the same slave in a round-robin manner. if two or more master requests arise at the same time, the master with the lowest number is first serviced, then the others are serviced in a round-robin manner. there are three round-robin algorithms implemented: 1. round-robin arbitration without default master 2. round-robin arbitration with last default master 3. round-robin arbitration with fixed default master ? round-robin arbitration without default master this is the main algorithm used by bus matrix arbiters. it allows the bus matrix to dispatch requests from different masters to the same slave in a pure round-robin manner. at the end of the current access, if no other request is pending, the slave is disconnected from all masters. this configuration incurs one latency cycle for the first access of a burst. arbitration without default master can be used for masters that perform significant bursts. ? round-robin arbitration with last default master this is a biased round-robin algorithm used by bus matrix arbiters. it allows the bus matrix to remove the one latency cycle for the last master that accessed the slave. at the end of the cur-
288 32117b?avr-03/11 at32uc3c rent transfer, if no other master request is pending, the slave remains connected to the last master that performed the acce ss. other non privileged masters still get one latency cycle if they want to access the same slave. this technique can be used for masters that mainly perform sin- gle accesses. ? round-robin arbitration with fixed default master this is another biased round-robin algorithm. it a llows the bus matrix arbiters to remove the one latency cycle for the fixed default master per slav e. at the end of the current access, the slave remains connected to its fixed default master. every request attempted by this fixed default mas- ter will not cause any latency whereas other non privileged masters w ill still get one latency cycle. this technique can be used for masters that mainly perform single accesses. 16.4.2.3 fixed priority arbitration this algorithm allows the bus matrix arbiters to dispatch the requests from different masters to the same slave by using the fixed priority defined by the user. if two or more master requests are active at the same time, the master with the highest priority number is serviced first. if two or more master requests with the same priority are active at the same time, the master with the highest number is serviced first. for each slave, the priority of each master may be defined through the priority registers for slaves (pras and prbs). 16.4.3 slave and master assignation the index number assigned to bus matrix slaves and masters are described in the module con- figuration section at the end of this chapter.
289 32117b?avr-03/11 at32uc3c 16.5 user interface table 16-1. hmatrix register memory map offset register name access reset value 0x0000 master configuration register 0 mcfg0 read/write 0x00000002 0x0004 master configuration register 1 mcfg1 read/write 0x00000002 0x0008 master configuration register 2 mcfg2 read/write 0x00000002 0x000c master configuration register 3 mcfg3 read/write 0x00000002 0x0010 master configuration register 4 mcfg4 read/write 0x00000002 0x0014 master configuration register 5 mcfg5 read/write 0x00000002 0x0018 master configuration register 6 mcfg6 read/write 0x00000002 0x001c master configuration register 7 mcfg7 read/write 0x00000002 0x0020 master configuration register 8 mcfg8 read/write 0x00000002 0x0024 master configuration register 9 mcfg9 read/write 0x00000002 0x0028 master configuration register 10 mcfg10 read/write 0x00000002 0x002c master configuration regi ster 11 mcfg11 read/write 0x00000002 0x0030 master configuration register 12 mcfg12 read/write 0x00000002 0x0034 master configuration register 13 mcfg13 read/write 0x00000002 0x0038 master configuration register 14 mcfg14 read/write 0x00000002 0x003c master configuration regi ster 15 mcfg15 read/write 0x00000002 0x0040 slave configuration register 0 scfg0 read/write 0x00000010 0x0044 slave configuration register 1 scfg1 read/write 0x00000010 0x0048 slave configuration register 2 scfg2 read/write 0x00000010 0x004c slave configuration register 3 scfg3 read/write 0x00000010 0x0050 slave configuration register 4 scfg4 read/write 0x00000010 0x0054 slave configuration register 5 scfg5 read/write 0x00000010 0x0058 slave configuration register 6 scfg6 read/write 0x00000010 0x005c slave configuration register 7 scfg7 read/write 0x00000010 0x0060 slave configuration register 8 scfg8 read/write 0x00000010 0x0064 slave configuration register 9 scfg9 read/write 0x00000010 0x0068 slave configuration register 10 scfg10 read/write 0x00000010 0x006c slave configuration register 11 scfg11 read/write 0x00000010 0x0070 slave configuration register 12 scfg12 read/write 0x00000010 0x0074 slave configuration register 13 scfg13 read/write 0x00000010 0x0078 slave configuration register 14 scfg14 read/write 0x00000010 0x007c slave configuration register 15 scfg15 read/write 0x00000010 0x0080 priority register a for slave 0 pras0 read/write 0x00000000 0x0084 priority register b for slave 0 prbs0 read/write 0x00000000 0x0088 priority register a for slave 1 pras1 read/write 0x00000000
290 32117b?avr-03/11 at32uc3c 0x008c priority register b for slave 1 prbs1 read/write 0x00000000 0x0090 priority register a for slave 2 pras2 read/write 0x00000000 0x0094 priority register b for slave 2 prbs2 read/write 0x00000000 0x0098 priority register a for slave 3 pras3 read/write 0x00000000 0x009c priority register b for slave 3 prbs3 read/write 0x00000000 0x00a0 priority register a for slave 4 pras4 read/write 0x00000000 0x00a4 priority register b for slave 4 prbs4 read/write 0x00000000 0x00a8 priority register a for slave 5 pras5 read/write 0x00000000 0x00ac priority register b for slave 5 prbs5 read/write 0x00000000 0x00b0 priority register a for slave 6 pras6 read/write 0x00000000 0x00b4 priority register b for slave 6 prbs6 read/write 0x00000000 0x00b8 priority register a for slave 7 pras7 read/write 0x00000000 0x00bc priority register b for slave 7 prbs7 read/write 0x00000000 0x00c0 priority register a for slave 8 pras8 read/write 0x00000000 0x00c4 priority register b for slave 8 prbs8 read/write 0x00000000 0x00c8 priority register a for slave 9 pras9 read/write 0x00000000 0x00cc priority register b for slave 9 prbs9 read/write 0x00000000 0x00d0 priority register a for slave 10 pras10 read/write 0x00000000 0x00d4 priority register b for slave 10 prbs10 read/write 0x00000000 0x00d8 priority register a for slave 11 pras11 read/write 0x00000000 0x00dc priority register b for slave 11 prbs11 read/write 0x00000000 0x00e0 priority register a for slave 12 pras12 read/write 0x00000000 0x00e4 priority register b for slave 12 prbs12 read/write 0x00000000 0x00e8 priority register a for slave 13 pras13 read/write 0x00000000 0x00ec priority register b for slave 13 prbs13 read/write 0x00000000 0x00f0 priority register a for slave 14 pras14 read/write 0x00000000 0x00f4 priority register b for slave 14 prbs14 read/write 0x00000000 0x00f8 priority register a for slave 15 pras15 read/write 0x00000000 0x00fc priority register b for slave 15 prbs15 read/write 0x00000000 0x0110 special function register 0 sfr0 read/write ? 0x0114 special function register 1 sfr1 read/write ? 0x0118 special function register 2 sfr2 read/write ? 0x011c special function register 3 sfr3 read/write ? 0x0120 special function register 4 sfr4 read/write ? 0x0124 special function register 5 sfr5 read/write ? 0x0128 special function register 6 sfr6 read/write ? table 16-1. hmatrix register memory map (continued) offset register name access reset value
291 32117b?avr-03/11 at32uc3c 0x012c special function register 7 sfr7 read/write ? 0x0130 special function register 8 sfr8 read/write ? 0x0134 special function register 9 sfr9 read/write ? 0x0138 special function register 10 sfr10 read/write ? 0x013c special function register 11 sfr11 read/write ? 0x0140 special function register 12 sfr12 read/write ? 0x0144 special function register 13 sfr13 read/write ? 0x0148 special function register 14 sfr14 read/write ? 0x014c special function register 15 sfr15 read/write ? table 16-1. hmatrix register memory map (continued) offset register name access reset value
292 32117b?avr-03/11 at32uc3c 16.5.1 master configuration registers name: mcfg0...mcfg15 access type: read/write offset: 0x00 - 0x3c reset value: 0x00000002 ? ulbt: undefined length burst type 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????? ulbt table 16-2. undefined length burst type ulbt undefined length burst type description 000 inifinite length burst no predicted end of burst is generated and theref ore incr bursts coming from this master cannot be broken. 001 single-access the undefined length burst is treated as a succession of single accesses, allowing re- arbitration at each beat of the incr burst. 010 4 beat burst the undefined length bu rst is split into a four-beat burst, allowing re-arbitration at each four-beat burst end. 011 8 beat burst the undefined length burst is split into an eight-beat burst, allowing re-arbitration at each eight-beat burst end. 100 16 beat burst the undefined length burst is split in to a sixteen-beat burst, allowing re-arbitration at each sixteen-beat burst end.
293 32117b?avr-03/11 at32uc3c 16.5.2 slave configuration registers name: scfg0...scfg15 access type: read/write offset: 0x40 - 0x7c reset value: 0x00000010 ? arbt: arbitration type 0: round-robin arbitration 1: fixed priority arbitration ? fixed_defmstr: fixed default master this is the number of the default master for this slave. only used if defmstr_type is 2. sp ecifying the number of a master which is not connected to the selected slave is equivalent to sett ing defmstr_type to 0. ? defmstr_type: default master type 0: no default master at the end of the current slave access, if no other master r equest is pending, the slave is disconnected from all masters. this results in a one cycle latenc y for the first access of a burst transfer or for a single access. 1: last default master at the end of the current slave access, if no other master req uest is pending, the slave stays connected to the last master hav ing accessed it. this results in not having one cycle latency when the last master tries to access the slave again. 2: fixed default master at the end of the current slave access, if no other master request is pending, the slav e connects to the fixed master the numbe r that has been written in the fixed_defmstr field. this results in not having one cycle latency when the fixed master tries to access the slave again. ? slot_cycle: maximum number of allowed cycles for a burst when the slot_cycle limit is reached for a burst, it may be broken by another master trying to access this slave. this limit has been placed to avoid locking a very slow slave when very long bursts are used. this limit must not be very small. unreas onably small values break every burst and the bus matrix arbitrates without performing any data transfer. 16 cycles is a reasonable value for slot_cycle. 31 30 29 28 27 26 25 24 ???????arbt 23 22 21 20 19 18 17 16 ? ? fixed_defmstr defmstr_type 15 14 13 12 11 10 9 8 ???????? 76543210 slot_cycle
294 32117b?avr-03/11 at32uc3c 16.5.3 bus matrix priority registers a for slaves register name: pras0...pras15 access type: read/write offset: - reset value: 0x00000000 ? mxpr: master x priority fixed priority of master x for accessing the selected slave. the higher the number, the higher the priority. 31 30 29 28 27 26 25 24 - - m7pr - - m6pr 23 22 21 20 19 18 17 16 - - m5pr - - m4pr 15 14 13 12 11 10 9 8 - - m3pr - - m2pr 76543210 - - m1pr - - m0pr
295 32117b?avr-03/11 at32uc3c 16.5.4 priority registers b for slaves name: prbs0...prbs15 access type: read/write offset: - reset value: 0x00000000 ? mxpr: master x priority fixed priority of master x for accessing the selected slave. the higher the number, the higher the priority. 31 30 29 28 27 26 25 24 - - m15pr - - m14pr 23 22 21 20 19 18 17 16 - - m13pr - - m12pr 15 14 13 12 11 10 9 8 - - m11pr - - m10pr 76543210 - - m9pr - - m8pr
296 32117b?avr-03/11 at32uc3c 16.5.5 special function registers name: sfr0...sfr15 access type: read/write offset: 0x110 - 0x14c reset value: - ? sfr: special function register fields those registers are not a hmatrix spec ific register. the field of those will be defined where they are used. 31 30 29 28 27 26 25 24 sfr 23 22 21 20 19 18 17 16 sfr 15 14 13 12 11 10 9 8 sfr 76543210 sfr
297 32117b?avr-03/11 at32uc3c 16.6 bus matrix connections accesses to unused areas returns an error result to the master requesting such an access. the bus matrix has the several masters and slaves. each master has its own bus and its own decoder, thus allowing a different memory mapping per master. the master number in the table below can be used to index the hmatrix contro l registers. for example, mcfg0 is associated with the cpu data master interface. each slave has its own arbiter, thus allowing a different arbitration per slave. the slave number in the table below can be used to index the hmatrix control registers. for example, scfg3 is associated with the internal sram slave interface. table 16-3. high speed bus masters master 0 cpu data master 1 cpu instruction master 2 cpu sab master 3 sau master 4 pdca master 5 mdma read master 6 mdma write master 7 usbc master 8 canif master 9 macb table 16-4. high speed bus slaves slave 0 internal flash slave 1 hsb-pb bridge a slave 2 hsb-pb bridge b slave 3 hsb-pb bridge c slave 4 internal sram slave 5 hsb ram slave 6 ebi slave 7 sau
298 32117b?avr-03/11 at32uc3c figure 16-1. hmatrix master / slave connections cpu data 0 cpu instruction 1 cpu sab 2 sau 3 internal flash 0 1 hsb-pb bridge a 2 hsb-pb bridge b 3 hmatrix masters 4 pdca 4 internal sram sau hsb-pb bridge c 5 hsb sram 6 ebi 7 mdma read 5 mdma write 6 usbc 7 canif 8 macb 9
299 32117b?avr-03/11 at32uc3c 17. external bus interface (ebi) rev.: 1.7.0.2 17.1 features ? optimized for application memory space support ? integrates two external memory controllers: ? static memory controller (smc) ? sdram controller (sdramc) ? optimized external bus: 16(or 8)-bit data bus ? up to 24-bit address bus, up to 16-mbytes addressable ? optimized pin multiplexing to redu ce latencies on external memories ? up to 4 chip selects, configurable assignment: ? static memory controll er on chip select 0 ? sdram controller or static memory controller on chip select 1 ? static memory controll er on chip select 2 ? static memory controll er on chip select 3 17.2 overview the external bus interface (ebi) is designed to ensure the successful data transfer between several external devices and the embedded memory controller of a 32-bit avr device. the static memory and sdram controlle rs are all featured external memory controllers on the ebi. these external memory controllers are capable of handling several types of external memory and peripheral devices, such as sram , prom, eprom, eeprom, flash, and sdram. the ebi handles data transfers with up to four external devices, each as signed to four address spaces defined by the embedded memory controller. data transfers are performed through a 16- 8)-bit data bus, an address bus of up to 24 bits, up to four chip select lines (ncs[3:0]), and sev- eral control pins that are generally multip lexed between the different external memory controllers.
300 32117b?avr-03/11 at32uc3c 17.3 block diagram figure 17-1. ebi block diagram 17.4 i/o lines description hsb hmatrix ebi sdram controller static memory controller mux logic peripheral bus i/o controller data[15:0] nwe1 nwe0 nrd ncs[3:0] addr[23:0] cas ras sda10 sdwe sdck sdcke nwait intc sdramc_irq chip select assignor address decoders sfr registers hsb-pb bridge
301 32117b?avr-03/11 at32uc3c table 17-1. ebi i/o lines description pin name alternate name pin description type active level ebi common lines data[15:0] data bus i/o smc dedicated lines addr[1] smc address bus line 1 output addr[12] smc address bus line 12 output addr[15] smc address bus line 15 output addr[23:18] smc address bu s line [23:18] output ncs[0] smc chip select line 0 output low ncs[2] smc chip select line 2 output low ncs[3] smc chip select line 3 output low nrd smc read signal output low nwait smc external wait signal input low nwe0 nwe0-nwe smc write enable1 or write enable output low sdramc dedicated lines sdck sdram clock output sdcke sdram clock enable output high sdwe sdram write enable output low sda10 sdram address bus line 10 output low ras - cas row and column signal output low smc/sdramc shared lines addr[0] dqm0 addr[0]-nbs0 sdramc dqm1 smc address bus line 0 or byte select 0 output addr[11:2] addr[9:0] addr[11:2] sdramc address bus lines [9:0] smc address bus lines [11:2] output addr[14:13] addr[9:0] addr[14:13] sdramc address bus lines [12:11] smc address bus lines [14:13] output addr[16] ba0 addr[16] sdramc bank 0 smc address bus line 16 output addr[17] ba1 addr[17] sdramc bank 1 smcaddress bus line 17 output ncs[1] ncs[1] sdcs smc chip select line 1 sdramc chip select output low nwe1 dqm1 nwe1-nbs1 sdramc dqm1 smc write enable1 or byte select 1 output
302 32117b?avr-03/11 at32uc3c 17.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 17.5.1 i/o lines the pins used for interfacing the compliant external devices may be multiplexed with i/o con- troller lines. the user must first configure the i/o controller to assign the ebi pins to their peripheral functions. 17.5.2 power management to prevent bus errors ebi operation must be terminated before entering sleep mode. 17.5.3 clocks a number of clocks can be selected as source for the ebi. the selected clock must be enabled by the power manager. the following clock sources are available: ? clk_ebi ? clk_sdramc ? clk_smc refer to table 17-2 on page 302 to configure those clocks. 17.5.4 interrupts the ebi interface has one interrupt line connected to the interrupt controller: ? sdramc_irq: interrupt signal coming from the sdramc handling the ebi interrupt requires configuring the interrupt controller before configuring the ebi. table 17-2. ebi clocks configuration clocks name clocks type type of the interfaced device sdram sram, prom, eprom, eeprom, flash clk_ebi hsb x x clk_sdramc pb x clk_smc pb x
303 32117b?avr-03/11 at32uc3c 17.5.5 hmatrix the ebi interface is connected to the hmatrix special function register 6 (sfr6). the user must first write to this hmatrix.sf r6 to configure the ebi correctly. 17.6 functional description the ebi transfers data between the internal hsb bus (handled by the hmatrix) and the exter- nal memories or peripheral devices. it controls the waveforms and the parameters of the external address, data and control busses and is composed of the following elements: ? the static memory controller (smc) ? the sdram controller (sdramc) ? a chip select assignment feature that assigns an hsb address space to the external devices ? a multiplex controller circuit that shares the pins between the different memory controllers 17.6.1 bus multiplexing the ebi offers a complete set of control signals that share the 16(8)-bit data lines, the address lines of up to 24 bits and the control signals through a multiplex logic operating in function of the memory area requests. multiplexing is specifically organized in or der to guarantee the maintenance of the address and output control lines at a stable state while no ex ternal access is being pe rformed. mult iplexing is also designed to respect the data float times defined in the memory controllers. furthermore, refresh cycles of the sdram are executed independently by the sdramc without delaying the other external memory controller accesses. 17.6.2 static memory controller for information on the static memory controller, refer to the static memory controller section. 17.6.3 sdram controller writing a one to the hmatrix.sfr6.cs1a bit enables the sdram logic. for information on the sdram contro ller, refer to the sdram section. table 17-3. ebi special function register fields description sfr6 bit number bit name description [31:2] reserved 1cs1a 0 = chip select 1 (ncs[1]) is connect ed to a static memory device. for each access to the ncs[1] memory space, all related pins act as smc pins 1 = chip select 1 (ncs[1]) is connected to a sdram device. for each access to the ncs[1] memory space, all re lated pins act as sdram pins (sdcs) 0 reserved
304 32117b?avr-03/11 at32uc3c 17.7 application example 17.7.1 hardware interface note: 1. nwe1 enables upper byte writes. nwe0 enables lower byte writes. 2. nbs1 enables upper byte writes. nbs0 enables lower byte writes. table 17-4. ebi pins and external static devices connections pins name pins of the interfaced device 8-bit static device 2 x 8-bit static devices 16-bit static device controller smc data[7:0] d[7:0] d[7:0] d[7:0] data[15:0] ? d[15:8] d[15:8] addr[0] a[0] ? nbs0 (2) addr[1] a[1] a[0] a[0] addr[23:2] a[23:2] a[22:1] a[22:1] ncs[0] - ncs[3] cs cs cs nrd oe oe oe nwe0 we we (1) we nwe1 ? we (1) nbs1 (2) table 17-5. ebi pins and external devices connections pins name pins of the interfaced device sdram controller sdramc data[7:0] d[7:0] data[15:8] d[15:8] addr[0] dqm0 addr[10:2] a[8:0] addr[11] a[9] sda10 a[10] addr[14:13] a[12:11] addr[16] ba0 addr[17] ba1 ncs[1] cs nwe1 dqm1 sdck clk sdcke cke
305 32117b?avr-03/11 at32uc3c ras ras cas cas sdwe we table 17-5. ebi pins and external devices connections (continued) pins name pins of the interfaced device sdram controller sdramc
306 32117b?avr-03/11 at32uc3c 17.7.2 connection examples figure 17-2 on page 306 shows an example of connections between the ebi and external devices. figure 17-2. ebi connections to memory devices ebi data[15:0] ras cas sdck sdcke sdwe addr[0] nwe1 nrd nwe0 sdram 2mx8 d[7:0] cs clk cke we ras cas dqm a[9:0] a[10] a[11] ba0 ba1 sdram 2mx8 d[7:0] cs clk cke we ras cas dqm a[9:0] a[10] a[11] ba0 ba1 data[7:0] data[15:8] addr[11:2] sda10 addr[13] addr[16] addr[17] addr[11:2] sda10 addr[13] addr[16] addr[17] sdck sdcke sdwe ras cas addr[0] sdck sdcke sdwe ras cas nwe1 sda10 addr[17:1] ncs[1] sram 128kx8 we oe cs d[7:0] a[16:0] sram 128kx8 we oe cs d[7:0] a[16:0] data[7:0] data[15:8] addr[17:1] addr[17:1] ncs[0] ncs[0] ncs[0] nrd nrd nwe0 nwe1
307 32117b?avr-03/11 at32uc3c 18. static memory controller (smc) rev. 1.0.6.5 18.1 features ? 4 chip selects available ? 16-mbytes address space per chip select ? 8- or 16-bit data bus ? word, halfword, byte transfers ? byte write or byte select lines ? programmable setup, pulse and hold ti me for read signals per chip select ? programmable setup, pulse and hold ti me for write signal s per chip select ? programmable data float time per chip select ? compliant with lcd module ? external wait request ? automatic switch to slow clock mode ? asynchronous read in page mode supporte d: page size ranges from 4 to 32 bytes 18.2 overview the static memory controller (smc) generates the signals that control the access to the exter- nal memory devices or peripheral devices. it has 4 chip selects and a 24-bit address bus. the 16-bit data bus can be configured to interface with 8-16-bit external devices. separate read and write control signals allow for direct memory and peripheral interfacing. read and write signal waveforms are fully parametrizable. the smc can manage wait requests from external devices to extend the current access. the smc is provided with an automatic slow clock mode. in slow clock mode, it switches from user- programmed waveforms to slow-rate specific waveforms on read and write signals. the smc supports asynchronous burst read in page mode access for page size up to 32 bytes.
308 32117b?avr-03/11 at32uc3c 18.3 block diagram figure 18-1. smc block diagram (ad_msb=23) 18.4 i/o lines description 18.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. smc chip select hmatrix power manager clk_smc smc i/o controller ncs[5:0] nrd nwe0 addr[0] nwe1 addr[1] addr[ad_msb:2] data[15:0] nwait user interface peripheral bus ncs[5:0] nrd nwr0/nwe a0/nbs0 nwr1/nbs1 a1/nwr2/nbs2 a[ad_msb:2] d[15:0] nwait ebi mux logic table 18-1. i/o lines description pin name pin description type active level ncs[3:0] chip select lines output low nrd read signal output low nwr0/nwe write 0/write enable signal output low a0/nbs0 address bit 0/byte 0 select signal output low nwr1/nbs1 write 1/byte 1 select signal output low a[23:2] address bus output d[15:0] data bus input/output nwait external wait signal input low
309 32117b?avr-03/11 at32uc3c 18.5.1 i/o lines the smc signals pass through the external bus in terface (ebi) module where they are multi- plexed. the user must first configure the i/o controller to assign the ebi pins corresponding to smc signals to their peripheral function. if the i/o lines of the ebi corresponding to smc signals are not used by the application, they can be us ed for other purposes by the i/o controller. 18.5.2 clocks the clock for the smc bus interface (clk_smc) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to disable the smc before disabling the clock, to avoid freezing the smc in an undefined state. 18.6 functional description 18.6.1 application example figure 18-2. smc connections to st atic memory devices 18.6.2 external memory mapping the smc provides up to 24 address lines, a[23:0] . this allows each chip select line to address up to 16mbytes of memory. if the physical memory device connected on one chip select is smaller than 16mbytes, it wraps around and appears to be repeated within this space. the smc correctly handles any valid access to the memory devi ce within the page (see figure 18-3 on page 310 ). a[23:0] is only significant for 8-bit memo ry, a[23:1] is used for 16-bit memory23. 128k x 8 sram d0-d7 cs oe we a0-a16 128k x 8 sram d0-d7 cs oe we a0-a16 d0-d15 nwr1/nbs1 a0/nbs0 nwr0/nwe ncs0 ncs2 ncs1 ncs3 ncs5 ncs4 nrd nrd a2-a18 static memory controller nwr0/nwe nwr1/nbs1 d8-d15 d0-d7 a2-a18 a2-a18
310 32117b?avr-03/11 at32uc3c figure 18-3. memory connections for six external devices 18.6.3 connection to external devices 18.6.3.1 data bus width a data bus width of 8 or 16 bits can be selected for each chip select. this option is controlled by the data bus width field in the mode register (mode.dbw) for the corresponding chip select. figure 18-4 on page 310 shows how to connect a 512k x 8-bit memory on ncs2. figure 18-5 on page 311 shows how to connect a 512k x 16-bit memory on ncs2. 18.6.3.2 byte write or byte select access each chip select with a 16-bit data bus can operate with one of two different types of write access: byte write or byte select access. this is controlled by the byte access type bit in the mode register (mode.bat) for th e corresponding chip select. figure 18-4. memory connection for an 8-bit data bus ncs[0] - ncs[5] nrd nwe a[ad_msb:0] d[15:0] smc ncs5 ncs4 ncs3 ncs2 ncs1 ncs0 8 or 16 memory enable memory enable memory enable memory enable memory enable memory enable output enable write enable a[ad_msb:0] d[15:0] or d[7:0] smc a0 nwe nrd ncs[2] a0 write enable output enable memory enable d[7:0] d[7:0] a[18:2] a[18:2] a1 a1
311 32117b?avr-03/11 at32uc3c figure 18-5. memory connection for a 16-bit data bus ?byte write access the byte write access mode supports one byte write signal per byte of the data bus and a single read signal. note that the smc does not allow boot in byte write access mode. ? for 16-bit devices: the smc provides nwr0 and nwr1 write signals for respectively byte0 (lower byte) and byte1 (upper byte) of a 16-bit bus. one single read signal (nrd) is provided. the byte write access mode is used to connect two 8-bit devices as a 16-bit memory. the byte write optio n is illustrated on figure 18-6 on page 312 . ?byte select access in this mode, read/write operations can be enabled /disabled at a byte level. one byte select line per byte of the data bus is provided. one nrd and one nwe signal control read and write. ? for 16-bit devices: the smc provides nbs0 and nbs1 selection signals for respectively byte0 (lower byte) and byte1 (upper byte) of a 16-bit bus. the byte select access is used to connect one 16-bit device. smc nbs0 nwe nrd ncs[2] low byte enable write enable output enable memory enable nbs1 high byte enable d[15:0] d[15:0] a[19:2] a[18:1] a[0] a1
312 32117b?avr-03/11 at32uc3c figure 18-6. connection of two 8-bit devices on a 16-bit bus: byte write option ?signal multiplexing depending on the mode.bat bit, only the write si gnals or the byte select signals are used. to save i/os at the external bus interface, control signals at the smc interface are multiplexed. for 16-bit devices, bit a0 of address is unused. when byte select option is selected, nwr1 is unused. when byte write option is selected, nbs0 to nbs1 are unused. table 18-3. smc multiplexed signal translation 18.6.4 standard read and write protocols in the following sections, the byte access type is not considered. byte select lines (nbs0 to nbs1) always have the same timing as the address bus (a). nwe represents either the nwe signal in byte select access type or one of the byte write lines (nwr0 to nwr1) in byte write smc a1 nwr0 nrd ncs[3] write enable read enable memory enable nwr1 write enable read enable memory enable d[7:0] d[7:0] d[15:8] d[15:8] a[24:2] a[23:1] a[23:1] a[0] a[0] signal name 16-bit bus 8-bit bus device type 1 x 16-bit 2 x 8-bit 1 x 8-bit byte access type (bat) byte select byte write nbs0_a0 nbs0 a0 nwe_nwr0 nwe nwr0 nwe nbs1_nwr1 nbs1 nwr1 nbs2_nwr2_a1 a1 a1 a1
313 32117b?avr-03/11 at32uc3c access type. nwr0 to nwr1 have the same ti mings and protocol as nwe. in the same way, ncs represents one of the ncs[0..3] chip select lines. 18.6.4.1 read waveforms the read cycle is shown on figure 18-7 on page 313 . the read cycle starts with the address setting on the memory address bus, i.e.: {a[23:2], a1, a0} for 8-bit devices {a[23:2], a1} for 16-bit devices figure 18-7. standard read cycle ?nrd waveform the nrd signal is characterized by a se tup timing, a pulse width, and a hold timing. 1. nrdsetup: the nrd setup time is defined as the setup of address before the nrd falling edge. 2. nrdpulse: the nrd pulse length is the time between nrd falling edge and nrd ris- ing edge. 3. nrdhold: the nrd hold time is defined as the hold time of address after the nrd ris- ing edge. ?ncs waveform similarly, the ncs signal can be divided into a setup time, pulse length and hold time. a[ad_msb:2] clk_smc nbs0, nbs1, a0, a1 nrd ncs d[15:0] ncsrdsetup nrdsetup nrdpulse ncsrdpulse nrdcycle nrdhold ncsrdhold
314 32117b?avr-03/11 at32uc3c 1. ncsrdsetup: the ncs setup time is defined as the setup time of address before the ncs falling edge. 2. ncsrdpulse: the ncs pulse length is t he time between ncs falling edge and ncs rising edge. 3. ncsrdhold: the ncs hold time is defined as the hold time of address after the ncs rising edge. ?read cycle the nrdcycle time is defined as the total duration of the read cycle, i.e., from the time where address is set on the address bus to the point where address may change. the total read cycle time is equal to: similarly, all nrd and ncs timings are defined separately for each chip select as an integer number of clk_smc cycles. to ensure that the nrd and ncs timings ar e coherent, the user must define the total read cycle instead of the hold timing. nrdcycle implicitly defines the nrd hold time and ncs hold time as: and, ?null delay setup and hold if null setup and hold parame ters are programmed for nrd and/or ncs, nrd and ncs remain active continuously in case of consecutive read cycles in the same memory (see figure 18-8 on page 315 ). nrdcycle nrdsetup nrdpulse nrdhold ++ = nrdcycle ncsrdsetup ncsrdpulse ncsrdhold ++ = nrdhold nrdcycle nrdsetup ? nrdpulse ? = ncsrdhold nrdcycle ncsrdsetup ? ncsrdpulse ? =
315 32117b?avr-03/11 at32uc3c figure 18-8. no setup, no hold on nrd, and ncs read signals ? null pulse programming null pulse is not permitted. pulse must be at least written to one. a null value leads to unpredictable behavior. 18.6.4.2 read mode as ncs and nrd waveforms are defined independently of one other, the smc needs to know when the read data is available on the data bus. the smc does not compare ncs and nrd tim- ings to know which signal rises first. the read mode bit in the mode register (mode.readmode) of the corresponding chip se lect indicates which signal of nrd and ncs controls the read operation. ?read is controlled by nrd (mode.readmode = 1) figure 18-9 on page 316 shows the waveforms of a read operation of a typical asynchronous ram. the read data is available t pacc after the falling edge of nrd, and turns to ?z? after the ris- ing edge of nrd. in this case, the mode.readmode bit must be written to one (read is controlled by nrd), to indicate th at data is availabl e with the rising edge of nrd. the smc sam- ples the read data internally on the rising ed ge of clk_smc that generates the rising edge of nrd, whatever the programmed waveform of ncs may be. clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 nrd ncs d[15:0] nrdsetup nrdpulse ncsrdpulse nrdcycle nrdcycle ncsrdpulse ncsrdpulse nrdpulse nrdcycle
316 32117b?avr-03/11 at32uc3c figure 18-9. readmode = 1: data is sampled by smc before the rising edge of nrd ?read is controlled by ncs (mode.readmode = 0) figure 18-10 on page 317 shows the typical read cycle of an lcd module. the read data is valid t pacc after the falling edge of the ncs signal and remains valid until the rising edge of ncs. data must be sampled when ncs is raised. in that case, the mode.readmode bit must be written to zero (read is controlled by ncs): the smc internally samples the data on the rising edge of cml_smc that generates the rising edge of ncs, whatever the programmed waveform of nrd may be. clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 nrd ncs d[15:0] t pacc data sampling
317 32117b?avr-03/11 at32uc3c figure 18-10. readmode = 0: data is sampled by smc before the rising edge of ncs 18.6.4.3 write waveforms the write protocol is similar to the read protocol. it is depicted in figure 18-11 on page 318 . the write cycle starts with the address setting on the memory address bus. ?nwe waveforms the nwe signal is characterized by a setu p timing, a pulse width and a hold timing. 1. nwesetup: the nwe setup time is defined as the setup of address and data before the nwe falling edge. 2. nwepulse: the nwe pulse length is the time between nwe falling edge and nwe rising edge. 3. nwehold: the nwe hold time is defined as the hold time of address and data after the nwe rising edge. the nwe waveforms apply to all byte-write lines in byte write access mode: nwr0 to nwr3. 18.6.4.4 ncs waveforms the ncs signal waveforms in write operation are not the same that those applied in read opera- tions, but are separately defined. 1. ncswrsetup: the ncs setup time is defined as the setup time of address before the ncs falling edge. 2. ncswrpulse: the ncs pulse length is th e time between ncs falling edge and ncs rising edge; 3. ncswrhold: the ncs hold time is defined as the hold time of address after the ncs rising edge. clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 nrd ncs d[15:0] t pacc data sampling
318 32117b?avr-03/11 at32uc3c figure 18-11. write cycle ?write cycle the write cycle time is defined as the total duration of the write cycle, that is, from the time where address is set on the address bus to the point where address may change. the total write cycle time is equal to: similarly, all nwe and ncs (write) timings are defined separately for each chip select as an integer num- ber of clk_smc cycles. to ensure that the nwe and ncs timings are coherent, the user must define the total write cycle instead of the hold timi ng. this implicitly defines the nwe hold time and ncs (write) hold times as: and, clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 nwe ncs nwesetup nwepulse ncswrpulse ncswrsetup nwecycle nwehold ncswrhold nwecycle nwesetup nwepulse nwehold ++ = nwecycle ncswrsetup ncswrpulse ncswrhold ++ = nwehold nwecycle nwesetup ? nwepulse ? = ncswrhold nwecycle ncswrsetup ? ncswrpulse ? =
319 32117b?avr-03/11 at32uc3c ?null delay setup and hold if null setup parameters are programmed for nwe and/or ncs, nwe and/or ncs remain active continuously in case of consecutive wr ite cycles in the same memory (see figure 18-12 on page 319 ). however, for devices that perform write operations on the rising edge of nwe or ncs, such as sram, either a setup or a hold must be programmed. figure 18-12. null setup and hold values of ncs and nwe in write cycle ?null pulse programming null pulse is not permitted. pulse must be at least written to one. a null value leads to unpredictable behavior. 18.6.4.5 write mode the write mode bit in the mode register (mode.writemode) of the corresponding chip select indicates which signal controls the write operation. ?write is controlled by nwe (mode.writemode = 1) figure 18-13 on page 320 shows the waveforms of a writ e operation with mode.writemode equal to one. the data is put on the bus during the pulse and hold steps of the nwe signal. the internal data buffers are turned out after the nwesetup time, and until the end of the write cycle, regardless of the programmed waveform on ncs. clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 nwe, nwe0, nwe1 ncs nwesetup nwepulse ncswrpulse ncswrsetup nwecycle d[15:0] nwecycle nwepulse ncswrpulse nwecycle
320 32117b?avr-03/11 at32uc3c figure 18-13. writemode = 1. the write operation is controlled by nwe ?write is controlled by ncs (mode.writemode = 0) figure 18-14 on page 320 shows the waveforms of a writ e operation with mode.writemode written to zero. the data is put on the bus during the pulse and hold steps of the ncs signal. the internal data buffers are turned out after the ncswrsetup time, and until the end of the write cycle, regardless of the programmed waveform on nwe. figure 18-14. writemode = 0. the write operation is controlled by ncs clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 nwe, nwr0, nwr1 ncs d[15:0] clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 nwe, nwr0, nwr1 ncs d[15:0]
321 32117b?avr-03/11 at32uc3c 18.6.4.6 coding timing parameters all timing parameters are defined for one chip select and are grouped together in one register according to their type. the setup register (setup) groups the definition of all setup parameters: ? nrdsetup, ncsrdsetup, nwesetup, and ncswrsetup. the pulse register (pulse) groups the definition of all pulse parameters: ? nrdpulse, ncsrdpulse, nwepulse, and ncswrpulse. the cycle register (cycle) groups the definition of all cycle parameters: ? nrdcycle, nwecycle. table 18-4 on page 321 shows how the timing parameters are coded and their permitted range. 18.6.4.7 usage restriction the smc does not check the validity of the user-programmed parameters. if the sum of setup and pulse parameters is larger than the corresponding cycle parameter, this leads to unpre- dictable behavior of the smc. for read operations: null but positive setup and hold of address and nrd and/or ncs can not be guaranteed at the memory interface because of the propagation dela y of theses signals through external logic and pads. if positive setup and hold values must be verified, then it is strictly recommended to pro- gram non-null values so as to cover possible skews between address, ncs and nrd signals. for write operations: if a null hold value is programmed on nwe, the smc can guarantee a positive hold of address, byte select lines, and ncs signal after the rising edge of nwe. this is true if the mode.write- mode bit is written to one. see section 18.6.5.2 . for read and write operations: a null value for pulse parameters is forbidden and may lead to unpredictable behavior. in read and write cycles, the setup and hold time parameters are defined in reference to the address bus. for external devices that require setup and hold time between ncs and nrd sig- nals (read), or between ncs and nwe signals (write), these setup and hold times must be converted into setup and hold times in reference to the address bus. table 18-4. coding and range of timing parameters coded value number of bits effective value permitted range coded value effective value setup [5:0] 6 128 x setup[5] + setup[4:0] 0 value 31 32 value 63 0 value 31 128 value 128+31 pulse [6:0] 7 256 x pulse[6] + pulse[5:0] 0 value 63 64 value 127 0 value 63 256 value 256+63 cycle [8:0] 9 256 x cycle[8:7] + cycle[6:0] 0 value 127 128 value 255 256 value 383 384 value 511 0 value 127 256 value 256+127 512 value 512+127 768 value 768+127
322 32117b?avr-03/11 at32uc3c 18.6.5 automatic wait states under certain circumstances, the smc automatica lly inserts idle cycles between accesses to avoid bus contention or operation conflict. 18.6.5.1 chip sele ct wait states the smc always inserts an idle cycle between two transfers on separate ch ip selects. this idle cycle ensures that there is no bus contention bet ween the deactivation of one device and the activation of the next one. during chip select wait state, all control li nes are turned inactive: nbs0 to nbs3, nwr0 to nwr3, ncs[0..5], nrd lines are all set to high level. figure 18-15 on page 322 illustrates a chip select wait stat e between access on chip select 0 (ncs0) and chip select 2 (ncs2). figure 18-15. chip select wait state between a read access on ncs0 and a write access on ncs2 18.6.5.2 early read wait state in some cases, the smc inserts a wait state cycle between a write access and a read access to allow time for the write cycle to end before the subsequent read cycle begins. this wait state is not generated in addition to a chip select wait state. the early read cycle thus only occurs between a write and read access to the same memory device (same chip select). clk_smc _msb:2] , nbs1, , a1 nrd nwe ncs0 ncs2 d[15:0] nrdcycle read to write wait state chip select wait state nwecycle
323 32117b?avr-03/11 at32uc3c an early read wait state is automatically inserted if at least one of the following conditions is valid: ? if the write controlling signal has no hold time and the read controlling signal has no setup time ( figure 18-16 on page 323 ). ? in ncs write controlled mode (mode.writemode = 0), if there is no hold timing on the ncs signal and the ncsrdsetup parameter is set to zero, regardless of the read mode ( figure 18-17 on page 324 ). the write operation must end with a ncs rising edge. without an early read wait state, the write operation could not complete properly. ? in nwe controlled mode (mode.writemode = 1) and if there is no hold timing (nwehold = 0), the feedback of the write control signal is used to control address, data, chip select, and byte select lines. if the extern al write control signal is not inactivated as expected due to load capacitances, an early read wait state is inserted and address, data and control signals are maintained one more cycle. see figure 18-18 on page 325 . figure 18-16. early read wait state: write with no hold followed by read with no setup. clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 nwe nrd d[15:0] no hold no setup read cycle early read wait state write cycle
324 32117b?avr-03/11 at32uc3c figure 18-17. early read wait state: ncs controlled write with no hold followed by a read with no setup. clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 nwe nrd d[15:0] no hold no setup read cycle (readmode=0 or readmode=1) early read wait state write cycle (writemode=0)
325 32117b?avr-03/11 at32uc3c figure 18-18. early read wait state: nwe-controlled write with no hold followed by a read with one set-up cycle. 18.6.5.3 reload user configuration wait state the user may change any of the configuration parameters by writing the smc user interface. when detecting that a new user configuration has been written in the user interface, the smc inserts a wait state before starting the next access. the so called ?reload user configuration wait state? is used by the smc to load the new set of parameters to apply to next accesses. the reload configuration wa it state is not applied in addition to the chip select wait state. if accesses before and after reprogramming the user interface are made to different devices (dif- ferent chip selects), then one single chip select wait state is applied. on the other hand, if accesses before and after writing the user interface are made to the same device, a reload configuration wait state is inserted, even if the change does not concern the cur- rent chip select. ?user procedure to insert a reload configuration wait state, the smc detects a write access to any mode register of the user interface. if the user only modifies timing registers (setup, pulse, cycle regis- ters) in the user interface, he must validate th e modification by writing the mode register, even if no change was made on the mode parameters. clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 internal write controlling signal external write controlling signal(nwe) nrd d[15:0] no hold read setup=1 write cycle (writemode = 1) early read wait state read cycle (readmode=0 or readmode=1)
326 32117b?avr-03/11 at32uc3c ?slow clock mode transition a reload configuration wait state is also inserted when the slow clock mode is entered or exited, after the end of the current transfer (see section 18.6.8 ). 18.6.5.4 read to write wait state due to an internal mechanism, a wait cycle is always inserted between consecutive read and write smc accesses. this wait cycle is referred to as a read to write wait stat e in this document. this wait cycle is applied in add ition to chip select and reload user configuration wait states when they are to be inserted. see figure 18-15 on page 322 . 18.6.6 data float wait states some memory devices are slow to release the exte rnal bus. for such devices, it is necessary to add wait states (data float wait states) after a read access: ? before starting a read access to a different external memory. ? before starting a write access to the same device or to a different external one. the data float output time (t df ) for each external memory device is programmed in the data float time field of the mode register (mod e.tdfcycles) for the corresponding chip select. the value of mode.tdfcycles indicates the number of data float wait cycles (between 0 and 15) before the external device releases the bus, and represents the time allowed for the data output to go to high impedance after the memory is disabled. data float wait states do not delay internal memory accesses. hence, a single access to an external memory with long t df will not slow down the executio n of a program from internal memory. the data float wait states management depends on the mode.readmode bit and the tdf optimization bit of the mode register (mode. tdfmode) for the corresponding chip select. 18.6.6.1 read mode writing a one to the mode.readmo de bit indicates to the smc that the nrd signal is respon- sible for turning off the tri-state buffers of the external memory device. the data float period then begins after the rising edge of the nrd signal and lasts mode.tdfcycles cycles of the clk_smc clock. when the read operation is controlled by the ncs signal (mode.readmode = 0), the mode.tdfcycles field gives the number of clk_smc cycles during which the data bus remains busy after the rising edge of ncs. figure 18-19 on page 327 illustrates the data float period in nrd-controlled mode (mode.readmode =1), assuming a data float period of two cycles (mode.tdfcycles = 2). figure 18-20 on page 327 shows the read operation when controlled by ncs (mode.read- mode = 0) and the mode.tdfcycles field equals to three.
327 32117b?avr-03/11 at32uc3c figure 18-19. tdf period in nrd controlled read access (tdfcycles = 2) figure 18-20. tdf period in ncs controlled r ead operation (tdfcycles = 3) clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 nrd ncs d[15:0] t pacc nrd controlled read operation tdf = 2 clock cycles clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 nrd ncs d[15:0] t pacc ncs controlled read operation tdf = 3 clock cycles
328 32117b?avr-03/11 at32uc3c 18.6.6.2 tdf optimization enabled (mode.tdfmode = 1) when the mode.tdfmode bit is written to one (tdf optimization is enabled), the smc takes advantage of the setup period of the next access to optimize the number of wait states cycle to insert. figure 18-21 on page 328 shows a read access controlled by nrd, followed by a write access controlled by nwe, on chip select 0. chip select 0 has been programmed with: nrdhold = 4; readmode = 1 (nrd controlled) nwesetup = 3; writemode = 1 (nwe controlled) tdfcycles = 6; tdfmode = 1 (optimization enabled). figure 18-21. tdf optimization: no tdf wait states are inserted if the tdf period is over when the next access begins 18.6.6.3 tdf optimization disabled (mode.tdfmode = 0) when optimization is disabled, data float wait states are inserted at the end of the read transfer, so that the data float period is ended when the second access begins. if the hold period of the read1 controlling signal ov erlaps the data float period, no additional data float wait states will be inserted. figure 18-22 on page 329 , figure 18-23 on page 329 and figure 18-24 on page 330 illustrate the cases: ? read access followed by a read access on another chip select. ? read access followed by a write access on another chip select. clk_smc a[ad_msb:2] nrd nwe ncs0 d[15:0] read access on ncs0 (nrd controlled) read to write wait state write access on ncs0 (nwe controlled) tdfcycles = 6 nwesetup = 3 nrdhold = 4
329 32117b?avr-03/11 at32uc3c ? read access followed by a write access on the same chip select. with no tdf optimization. figure 18-22. tdf optimization disabled (mode.tdfmode = 0). tdf wait states between two read accesses on dif- ferent chip selects. figure 18-23. tdf optimization disabled (mode.tdfmode= 0). tdf wait states between a read and a write access on different chip selects. clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 read1 controlling signal(nrd) read2 controlling signal(nrd) d[15:0] read1 hold = 1 read1 cycle tdfcycles = 6 chip select wait state 5 tdf wait states tdfcycles = 6 read2 setup = 1 read 2 cycle tdfmode=0 (optimization disabled) clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 read1 controlling signal(nrd) write2 controlling signal(nwe) d[15:0] read1 cycle tdfcycles = 4 chip select wait state read1 hold = 1 tdfcycles = 4 read to write wait state 2 tdf wait states write2 setup = 1 write 2 cycle tdfmode=0 (optimization disabled)
330 32117b?avr-03/11 at32uc3c figure 18-24. tdf optimization disabled (mode.tdfmode = 0). tdf wa it states between read and write accesses on the same chip select. 18.6.7 external wait any access can be extended by an external device using the nw ait input signal of the smc. the external wait mode field of the mode register (mode.exnwmode) on the corresponding chip select must be written to either two (frozen mode) or three (ready mode). when the mode.exnwmode field is written to zero (disabled), the nwait signal is simply ignored on the corresponding chip select. the nwait signal delays the read or write operation in regards to the read or write controlling signal, depending on the read and wr ite modes of the corresponding chip select. 18.6.7.1 restriction when one of the mode.exnwmode is enabled, it is mandatory to program at least one hold cycle for the read/write controlling signal. for that reason, the nwait signal cannot be used in page mode ( section 18.6.9 ), or in slow clock mode ( section 18.6.8 ). the nwait signal is assumed to be a response of the external device to the read/write request of the smc. then nwait is examined by the smc only in the pulse state of the read or write controlling signal. the assertion of the nwait signal outside th e expected period has no impact on smc behavior. 18.6.7.2 frozen mode when the external device asserts the nwait signal (active low), and after internal synchroniza- tion of this signal, the smc state is frozen, i.e., smc internal counters are frozen, and all control signals remain unchanged. when the synchroniz ed nwait signal is deasserted, the smc com- pletes the access, resuming the access from the point where it was stopped. see figure 18-25 on page 331 . this mode must be selected when the external device uses the nwait signal to delay the access and to freeze the smc. clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 read1 controlling signal(nrd) write2 controlling signal(nwe) d[15:0] read1 hold = 1 tdfcycles = 5 read1 cycle tdfcycles = 5 read to write wait state 4 tdf wait states write2 setup = 1 write 2 cycle tdfmode=0 (optimization disabled)
331 32117b?avr-03/11 at32uc3c the assertion of the nwait sign al outside the expected period is ignored as illustrated in figure 18-26 on page 332 . figure 18-25. write access with nwait assertion in frozen mode (mode.exnwmode = 2). clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 nwe ncs d[15:0] 654 4 3 3 2 21 1 2 1 22 1 0 0 frozen state nwait internally synchronized nwait signal write cycle exnwmode = 2 (frozen) writemode = 1 (nwe controlled) nwepulse = 5 ncswrpulse = 7
332 32117b?avr-03/11 at32uc3c figure 18-26. read access with nwait assertion in frozen mode (mode.exnwmode = 2). clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 ncs nrd nwait internally synchronized nwait signal exnwmode = 2 (frozen) readmode = 0 (ncs controlled) nrdpulse = 2, nrdhold = 6 ncsrdpulse = 5, ncsrdhold = 3 read cycle assertion is ignored 43 2 10 22 1 0 5 55 4 3 2 21 10 0 frozen state
333 32117b?avr-03/11 at32uc3c 18.6.7.3 ready mode in ready mode (mode.exnwmode = 3), the smc behaves differently. normally, the smc begins the access by down counting the setup and pulse counters of the read/write controlling signal. in the last cycle of the pulse phase, the resynchronized nwait signal is examined. if asserted, the smc suspends the access as shown in figure 18-27 on page 333 and figure 18-28 on page 334 . after deassertion, the access is completed: the hold step of the access is performed. this mode must be selected when the external de vice uses deassertion of the nwait signal to indicate its ability to complete the read or write operation. if the nwait signal is deasserted before the end of the pulse, or asserted after the end of the pulse of the controlling read/write signal, it has no impact on the access length as shown in fig- ure 18-28 on page 334 . figure 18-27. nwait assertion in write access: ready mode (mode.exnwmode = 3). clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 nwe ncs d[15:0] 654 4 3 3 2 21 0 1 0 11 0 frozen state nwait internally synchronized nwait signal w rite cycle exnwmode = 3 (ready mode) writemode = 1 (nwe_controlled) nwepulse = 5 ncswrpulse = 7 0
334 32117b?avr-03/11 at32uc3c figure 18-28. nwait assertion in read access : ready mode (exnwmode = 3). clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 ncs nrd 6 6 5 5 4 4 3 2 3 1 21 0 nwait internally synchronized nwait signal read cycle exnwmode = 3 (ready mode) readmode = 0 (ncs_controlled) nrdpulse = 7 ncsrdpulse = 7 1 0 0 assertion is ignored assertion is ignored wait state
335 32117b?avr-03/11 at32uc3c 18.6.7.4 nwait latency and read/write timings there may be a latency between the assertion of the read/w rite controlling signal and the asser- tion of the nwait signal by the device. t he programmed pulse length of the read/write controlling signal must be at least equal to this latency plus the two cy cles of resynchronization plus one cycle. otherwise, the smc may enter the hold state of the access without detecting the nwait signal assertion. this is true in frozen mode as well as in ready mode. th is is illustrated on figure 18-29 on page 335 . when the mode.exnwmode field is enabled (ready or frozen), the user must program a pulse length of the read and write controlling si gnal of at least: figure 18-29. nwait latency minimal pulse length nwait latency 2 synchronization cycles 1 cycle ++ = wait state 0 1 2 3 4 clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 nrd nwait nternally synchronized nwait signal minimal pulse length 0 0 nwait latency 2 cycle resynchronization read cycle exnwmode = 2 or 3 readmode = 1 (nrd controlled) nrdpulse = 5
336 32117b?avr-03/11 at32uc3c 18.6.8 slow clock mode the smc is able to automatically apply a set of ?slow clock mode? read/write waveforms when an internal signal driven by the smc?s po wer management controller is asserted because clk_smc has been turned to a very slow clock rate (typically 32 khz clock rate). in this mode, the user-programmed waveforms are ignored and the slow clock mode waveforms are applied. this mode is provided so as to avoid reprogram ming the user interface with appropriate wave- forms at very slow clock rate. when activated, the slow mode is active on all chip selects. 18.6.8.1 slow clock mode waveforms figure 18-30 on page 336 illustrates the read and write operations in slow clock mode. they are valid on all chip selects. table 18-5 on page 336 indicates the value of read and write parame- ters in slow clock mode. figure 18-30. read and write cycles in slow clock mode clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 ncs nwe nwecycles = 3 slow clock mode write 1 1 1 clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 ncs nrd slow clock mode read nrdcycles = 2 1 1 table 18-5. read and write timing parameters in slow clock mode read parameters duration (cycles) write parameters duration (cycles) nrdsetup 1 nwesetup 1 nrdpulse 1 nwepulse 1 ncsrdsetup 0 ncswrsetup 0 ncsrdpulse 2 ncswrpulse 3 nrdcycle 2 nwecycle 3
337 32117b?avr-03/11 at32uc3c 18.6.8.2 switching from (to) slow clock mode to (from) normal mode when switching from slow clock mode to the nor mal mode, the current slow clock mode transfer is completed at high clock rate, with the set of slow clock mode parameters. see figure 18-31 on page 337 . the external device may not be fast enough to support such timings. figure 18-32 on page 338 illustrates the recommended procedur e to properly switch from one mode to the other. figure 18-31. clock rate transition occurs while the smc is performing a write operation clk_smc a[ad_msb:2] nbs0, nbs1, a0, a1 ncs nwe slow clock mode internal signal from pm this write cycle finishes with the slow clock mode set of parameters after the clock rate transition nwecycle = 3 slow clock mode write slow clock mode write 11 1 1 1 1 2 3 2 nwecycle = 7 normal mode write slow clock mode transition is detected: reload configuration wait state
338 32117b?avr-03/11 at32uc3c figure 18-32. recommended procedure to switch from slow clock mo de to normal mode or from normal mode to slow clock mode 18.6.9 asynchronous page mode the smc supports asynchronous burst reads in page mode, providing that the page mode enabled bit is written to one in the mode register (mode.pmen). the page size must be con- figured in the page size field in the mode register (mode.ps) to 4, 8, 16, or 32 bytes. the page defines a set of consecutive bytes into memory. a 4-byte page (resp. 8-, 16-, 32-byte page) is always aligned to 4-byte boundaries (resp. 8-, 16-, 32-byte boundaries) of memory. the msb of data address defines the address of the page in memory, the lsb of address define the address of the data in the page as detailed in table 18-6 on page 338 . with page mode memory devices, the first access to one page (t pa ) takes longer than the subse- quent accesses to the page (t sa ) as shown in figure 18-33 on page 339 . when in page mode, the smc enables the user to define different r ead timings for the first access within one page, and next accesses within the page. notes: 1. a denotes the address bus of the memory device 2. for 16-bit devices, the bit 0 of address is ignored. 18.6.9.1 protocol and timings in page mode figure 18-33 on page 339 shows the nrd and ncs timings in page mode access. clk_smc slow clock mode internal signal from pm a[ad_msb:2] nbs0, nbs1, a0, a1 nwe ncs 11 slow clock mode write 23 2 idle state reload configuration wait state normal mode write 1 table 18-6. page address and data address within a page page size page address (1) data address in the page (2) 4 bytes a[23:2] a[1:0] 8 bytes a[23:3] a[2:0] 16 bytes a[23:4] a[3:0] 32 bytes a[23:5] a[4:0]
339 32117b?avr-03/11 at32uc3c figure 18-33. page mode read protocol (address msb and lsb are defined in table 18-6 on page 338 ) the nrd and ncs signals are held low during all read transfers, whatever the programmed val- ues of the setup and hold timings in the us er interface may be. moreover, the nrd and ncs timings are identical. the pulse length of the first access to the page is defined with the pulse.ncsrdpulse field value. the pulse length of subsequent accesses within the page are defined using the pulse.nrdpulse field value. in page mode, the programming of the read timings is described in table 18-7 on page 339 : the smc does not check the coherency of timi ngs. it will always apply the ncsrdpulse tim- ings as page access timing (t pa ) and the nrdpulse for accesses to the page (t sa ), even if the programmed value for t pa is shorter than the programmed value for t sa . 18.6.9.2 byte access type in page mode the byte access type configuration remains active in page mode. for 16-bit or 32-bit page mode devices that require byte select ion signals, configure the mode.bat bit to zero (byte select access type). clk_smc a[msb] a[lsb] ncs nrd d[15:0] t pa ncsrdpulse t sa nrdpulse nrdpulse t sa table 18-7. programming of read timings in page mode parameter value definition readmode ?x? no impact ncsrdsetup ?x? no impact ncsrdpulse t pa access time of first access to the page nrdsetup ?x? no impact nrdpulse t sa access time of subsequent accesses in the page nrdcycle ?x? no impact
340 32117b?avr-03/11 at32uc3c 18.6.9.3 page mode restriction the page mode is not compatible with the use of the nwait signal. using the page mode and the nwait signal may lead to unpredictable behavior. 18.6.9.4 sequential and non-sequential accesses if the chip select and the msb of addresses as defined in table 18-6 on page 338 are identical, then the current access lies in the same page as the previous one, and no page break occurs. using this information, all data within the same page, sequential or not sequential, are accessed with a minimum access time (t sa ). figure 18-34 on page 340 illustrates access to an 8-bit mem- ory device in page mode, with 8-byte pages. access to d1 causes a page access with a long access time (t pa ). accesses to d3 and d7, though they are not sequential accesses, only require a short access time (t sa ). if the msb of addresses are different, the smc performs the access of a new page. in the same way, if the chip select is diffe rent from the previous access, a page break occurs. if two sequen- tial accesses are made to the page mode memory , but separated by an other internal or external peripheral access, a page break occurs on the second access because the chip select of the device was deasserted between both accesses. figure 18-34. access to non-sequential data within the same page clk_smc a[ad_msb:3] a[2], a1, a0 ncs nrd d[7:0] a1 page address a3 a7 d1 d3 d7 ncsrdpulse nrdpulse nrdpulse
341 32117b?avr-03/11 at32uc3c 18.7 user interface the smc is programmed using the registers listed in table 18-8 on page 341 . for each chip select, a set of four registers is used to program the parameters of the external device connected on it. in table 18-8 on page 341 , ?cs_number? denotes the chip select number. sixteen bytes (0x10) are required per chip select. the user must complete writing the configuration by writing anyone of the mode registers. table 18-8. smc register memory map offset register register name access reset 0x00 + cs_number*0x10 setup re gister setup read/write 0x01010101 0x04 + cs_number*0x10 pulse register pulse read/write 0x01010101 0x08 + cs_number*0x10 cycle register cycle read/write 0x00030003 0x0c + cs_number*0x10 mode register mode read/write 0x10002103
342 32117b?avr-03/11 at32uc3c 18.7.1 setup register register name: setup access type: read/write offset: 0x00 + cs_number*0x10 reset value: 0x01010101 ? ncsrdsetup: ncs setup length in read access in read access, the ncs signal setup length is defined as: ? nrdsetup: nrd setup length the nrd signal setup length is defined in clock cycles as: ? ncswrsetup: ncs setup length in write access in write access, the ncs signal setup length is defined as: ? nwesetup: nwe setup length the nwe signal setup length is defined as: 31 30 29 28 27 26 25 24 ?? ncsrdsetup 23 22 21 20 19 18 17 16 ?? nrdsetup 15 14 13 12 11 10 9 8 ?? ncswrsetup 76543210 ?? nwesetup ncs setup length in read access 128 ncsrdsetup 5 [] ncsrdsetup 4:0 [] + () clock cycles = nrd setup length 128 nrdsetup 5 [] nrdsetup 4:0 [] + () clock cycles = ncs setup length in write access 128 ncswrsetup 5 [] ncswrsetup 4:0 [] + () clock cycles = nwe setup length 128 nwesetup 5 [] nwesetup 4:0 [] + () clock cycles =
343 32117b?avr-03/11 at32uc3c 18.7.2 pulse register register name: pulse access type: read/write offset: 0x04 + cs_number*0x10 reset value: 0x01010101 ? ncsrdpulse: ncs pulse length in read access in standard read access, the ncs signal pulse length is defined as: the ncs pulse lengt h must be at least one clock cycle. in page mode read access, the ncsrdpulse field defines the duration of the first access to one page. ? nrdpulse: nrd pulse length in standard read access, the nrd signal puls e length is defined in clock cycles as: the nrd pulse length must be at least one clock cycle. in page mode read access, the nrdpulse field defines t he duration of the subsequent accesses in the page. ? ncswrpulse: ncs pulse length in write access in write access, the ncs signal pulse length is defined as: the ncs pulse lengt h must be at least one clock cycle. ? nwepulse: nw e pulse length the nwe signal pulse length is defined as: the nwe pulse leng th must be at least one clock cycle. 31 30 29 28 27 26 25 24 ? ncsrdpulse 23 22 21 20 19 18 17 16 ? nrdpulse 15 14 13 12 11 10 9 8 ? ncswrpulse 76543210 ? nwepulse ncs pulse length in read access 256 ncsrdpulse 6 [] ncsrdpulse 5:0 [] + () clock cycles = nrd pulse length 256 nrdpulse 6 [] nrdpulse 5:0 [] + () clock cycles = ncs pulse length in write access 256 ncswrpulse 6 [] ncswrpulse 5:0 [] + () clock cycles = nwe pulse length 256 nwepulse 6 [] nwepulse 5:0 [] + () clock cycles =
344 32117b?avr-03/11 at32uc3c 18.7.3 cycle register register name: cycle access type: read/write offset: 0x08 + cs_number*0x10 reset value: 0x00030003 ? nrdcycle[8:0]: total read cycle length the total read cycle leng th is the total duration in clock cycles of the read cycle. it is equal to the sum of the setup, pulse and hold steps of the nrd and ncs signals. it is defined as: ? nwecycle[8:0]: total write cycle length the total write cycle length is the total duration in clock cycles of the write cycle. it is equal to the sum of the setup, pul se and hold steps of the nwe and ncs signals. it is defined as: 31 30 29 28 27 26 25 24 ??????? nrdcycle[8] 23 22 21 20 19 18 17 16 nrdcycle[7:0] 15 14 13 12 11 10 9 8 ??????? nwecycle[8] 76543210 nwecycle[7:0] read cycle length 256 nrdcycle 8:7 [] nrdcycle 6:0 [] + () clock cycles = write cycle length 256 nwecycle 8:7 [] nwecycle 6:0 [] + () clock cycles =
345 32117b?avr-03/11 at32uc3c 18.7.4 mode register register name: mode access type: read/write offset: 0x0c + cs_number*0x10 reset value: 0x10002103 ? ps: page size if page mode is enabled, this field indicates the size of the page in bytes. ? pmen: page mode enabled 1: asynchronous burst read in page mode is applied on the corresponding chip select. 0: standard read is applied. ? tdfmode: tdf optimization 1: tdf optimization is enabled. the number of tdf wait states is optimized using the setup period of the next read/write access. 0: tdf optimization is disabled.the number of tdf wait states is inserted before the next access begins. ? tdfcycles: data float time this field gives the integer numb er of clock cycles required by the external de vice to release the dat a after the rising edge o f the read controlling signal. the smc always provide one full cycle of bus turnaround after the tdfcycles period. the external bus cannot be used by another chip select during tdfcycle s plus one cycles. from 0 up to 15 tdfcycles can be set. 31 30 29 28 27 26 25 24 ?? ps ??? pmen 23 22 21 20 19 18 17 16 ??? tdfmode tdfcycles 15 14 13 12 11 10 9 8 ?? dbw ??? bat 76543210 ?? exnwmode ??writemode readmode ps page size 0 4-byte page 1 8-byte page 2 16-byte page 3 32-byte page
346 32117b?avr-03/11 at32uc3c ? dbw: data bus width ? bat: byte access type this field is used only if dbw defines a 16-bit data bus. ? exnwmode: external wait mode the nwait signal is used to extend the current read or write signal. it is only taken into account during the pulse phase of th e read and write contro lling signal. when the use of nwai t is enabled, at least one cycle ho ld duration must be programmed for the read and write controlling signal. ? writemode: write mode 1: the write operation is controlled by the nwe signal. if td f optimization is enabled (tdfmode =1), tdf wait states will be inserted after the setup of nwe. 0: the write operation is controlled by the ncs signal. if tdf opt imization is enabled (tdfmode =1), tdf wait states will be inserted after the setup of ncs. dbw data bus width 08-bit bus 116-bit bus 2 reserved 3 reserved bat byte access type 0 byte select access type: write operation is controlled using ncs, nwe, nbs0, nbs1 read operation is controlled using ncs, nrd, nbs0, nbs1 1 byte write access type: write operation is controlled using ncs, nwr0, nwr1 read operation is controlled using ncs and nrd exnwmode external nwait mode 0 disabled: the nwait input signal is ignored on the corresponding chip select. 1 reserved 2 frozen mode: if asserted, the nwait signal freezes the current read or write cycle. after deassertion, the read or write cycle is resumed from the poi nt where it was stopped. 3 ready mode: the nwait signal indicates the availability of the external device at the end of the pu lse of the controlling read or write signal, to complete the access. if high, the ac cess normally completes. if low, the access is extended until nwait returns high.
347 32117b?avr-03/11 at32uc3c ? readmode: read mode readmode read access mode 0 the read operation is controlled by the ncs signal. if tdf are programmed, the external bus is marked busy after the rising edge of ncs. if tdf optimization is enabled (tdfmode = 1), tdf wa it states are inserted after the setup of ncs. 1 the read operation is controlled by the nrd signal. if tdf cycles are programmed, the external bus is marked busy after the rising edge of nrd. if tdf optimization is enabled (tdfmode =1), tdf wa it states are inserted after the setup of nrd.
348 32117b?avr-03/11 at32uc3c 19. sdram controller (sdramc) rev: 2.2.0.4 19.1 features ? 128-mbytes address space ? numerous configurations supported ? 2k, 4k, 8k row address memory parts ? sdram with two or four internal banks ? sdram with 16-bit data path ? programming facilities ? word, halfword, byte access ? automatic page break when memory boundary has been reached ? multibank ping-pong access ? timing parameters specified by software ? automatic refresh operation, refresh rate is programmable ? automatic update of ds, tcr and pa sr parameters (mobile sdram devices) ? energy-saving capabilities ? self-refresh, power-down, and deep power-down modes supported ? supports mobile sdram devices ? error detection ? refresh error interrupt ? sdram power-up initialization by software ? cas latency of one, two, and three supported ? auto precharge command not used 19.2 overview the sdram controller (sdramc) extends the memory capabilities of a chip by providing the interface to an external 16-bit sdram device. the page size supports ranges from 2048 to 8192 and the number of columns from 256 to 2048. it supports byte (8-bit) and halfword (16-bit) accesses. the sdramc supports a read or write burst length of one location. it keeps track of the active row in each bank, thus maximizing sdram perfo rmance, e.g., the application may be placed in one bank and data in the other banks. so as to optimize performance, it is advisable to avoid accessing different rows in the same bank. the sdramc supports a cas latency of one, two, or three and optimizes the read access depending on the frequency. the different modes available (self refresh, power-down, and deep power-down modes) mini- mize power consumption on the sdram device.
349 32117b?avr-03/11 at32uc3c 19.3 block diagram figure 19-1. sdram controller block diagram 19.4 i/o lines description memory controller power manager clk_sdramc sdramc chip select sdramc interrupt sdramc user interface peripheral bus i/o controller sdcs sdck sdcke ba[1:0] ras cas sdwe dqm[0] sdramc_a[9:0] d[15:0] ebi mux logic data[15:0] sdck sdcke ncs[1] ras cas addr[17:16] sdwe addr[0] dqm[1] nwe1 addr[11:2] sdramc_a[10] sda10 sdramc_a[12:11] addr[13:14] table 19-1. i/o lines description name description type active level sdck sdram clock output sdcke sdram clock enable output high sdcs sdram chip select output low ba[1:0] bank sele ct signals output ras row signal output low cas column signal output low sdwe sdram write enable output low
350 32117b?avr-03/11 at32uc3c 19.5 application example 19.5.1 hardware interface figure 19-2 on page 350 shows an example of sdram devi ce connection using a 16-bit data bus width. it is important to note that this example is given for a direct connection of the devices to the sdramc, without external bus interface or i/o controller multiplexing. figure 19-2. sdram controller connections to sdra m devices: 16-bit data bus width 19.5.2 software interface the sdram address space is organized into banks, rows, and columns. the sdramc allows mapping different memory types according to the values set in the sdramc configuration reg- ister (cr). the sdramc?s function is to ma ke the sdram device access protocol transparent to the user. table 19-2 on page 351 to table 19-4 on page 351 illustrate the sdram device memory map- ping seen by the user in correlation with the device structure. various configurations are illustrated. dqm[1:0] data mask enable signals output high sdramc_a[12:0] address bus output d[15:0] data bus input/output table 19-1. i/o lines description name description type active level 2mx8 sdram d0-d7 cs dqm clk cke we ras cas a0-a9 a11 ba0 a10 ba1 sdramc_a10 ba0 ba1 2mx8 sdram d0-d7 cs dqm clk cke we ras cas a0-a9 a11 ba0 a10 ba1 sdramc_a10 ba0 ba1 sdcs ba1 ba0 sdramc_a[0-12] sdram controller dqm[0-1] sdwe sdcke sdck cas ras d0-d31 dqm0 d0-d7 d8-d15 dqm1
351 32117b?avr-03/11 at32uc3c 19.5.2.1 16-bit memory data bus width notes: 1. m0 is the byte address inside a 16-bit halfword. 19.6 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 19.6.1 i/o lines the sdramc module signals pass through the external bus interface (ebi) module where they are multiplexed. the user must first configure the i/o controller to assign the ebi pins corre- sponding to sdramc signals to their peripheral function. if i/o lines of the ebi corresponding to sdramc signals are not used by the application, they can be used for other purposes by the i/o controller. 19.6.2 power management the sdramc must be properly stopped before entering in reset mode, i.e., the user must issue a deep power mode command in the mode (md) register and wait for the command to be completed. table 19-2. sdram configuration mapping: 2k rows, 256/512/1024/2048 columns cpu address line 272625242322212019181716151413121110987654321 0 ba[1:0] row[10:0] column[7:0] m0 ba[1:0] row[10:0] column[8:0] m0 ba[1:0] row[10:0] column[9:0] m0 ba[1:0] row[10:0] column[10:0] m0 table 19-3. sdram configuration mapping: 4k rows, 256/512/1024/2048 columns cpu address line 272625242322212019181716151413121110987654321 0 ba[1:0] row[11:0] column[7:0] m0 ba[1:0] row[11:0] column[8:0] m0 ba[1:0] row[11:0] column[9:0] m0 ba[1:0] row[11:0] column[10:0] m0 table 19-4. sdram configuration mapping: 8k rows, 256/512/1024/2048 columns cpu address line 272625242322212019181716151413121110987654321 0 ba[1:0] row[12:0] column[7:0] m0 ba[1:0] row[12:0] column[8:0] m0 ba[1:0] row[12:0] column[9:0] m0 ba[1:0] row[12:0] column[10:0] m0
352 32117b?avr-03/11 at32uc3c 19.6.3 clocks the clock for the sdramc bus interface (clk _sdramc) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to disable the sdramc before disabling the clock, to avoid freezing the sdramc in an undefined state. 19.6.4 interrupts the sdramc interrupt request line is connected to the interrupt controller. using the sdramc interrupt requires the interrupt controller to be programmed first. 19.7 functional description 19.7.1 sdram device initialization the initialization sequence is generated by softw are. the sdram devices are initialized by the following sequence: 1. sdram features must be defined in the cr register by writing the following fields with the desired value: asynchronous timings (txsr, tras, trcd, trp, trc, and twr), number of columns (nc), numb er of rows (nr), number of banks (nb), cas latency (cas), and the data bus width (dbw). 2. for mobile sdram devices, temperature compensated self refresh (tcsr), drive strength (ds) and partial array self refresh (pasr) fields must be defined in the low power register (lpr). 3. the memory device type field must be defined in the memory device register (mdr.md). 4. a no operation (nop) command must be i ssued to the sdram devices to start the sdram clock. the user must write the value one to the command mode field in the sdramc mode register (mr.mode) and perform a write access to any sdram address. 5. a minimum pause of 200s is provided to precede any signal toggle. 6. an all banks precharge command must be issued to the sdram devices. the user must write the value two to the mr.mode field and perform a write access to any sdram address. 7. eight auto refresh commands are provided. the user must write the value four to the mr.mode field and performs a write access to any sdram location eight times. 8. a load mode register command must be issued to program the parameters of the sdram devices in its mode register, in particular cas latency, burst type, and burst length. the user must write the value three to the mr.mode field and perform a write access to the sdram. the write address must be chosen so that ba[1:0] are set to zero. see section 19.8.1 for details about load mode register command. 9. for mobile sdram initialization, an extended load mode register command must be issued to program the sdram devices parame ters (tcsr, pasr, ds). the user must write the value five to the mr.mode field and perform a write access to the sdram. the write address must be chosen so that ba[1] or ba[0] are equal to one. see section 19.8.1 for details about extended load mode register command. 10. the user must go into normal mode, writing the value 0 to the mr.mode field and per- forming a write access at any location in the sdram. 11. write the refresh rate into the refresh timer count field in the refresh timer register (tr.count). the refresh rate is the delay between two successive refresh cycles. the sdram device requires a refresh every 15 .625s or 7.81s. with a 100mhz fre-
353 32117b?avr-03/11 at32uc3c quency, the tr register must be written with the value 1562 (15.625 s x 100 mhz) or 781 (7.81 s x 100 mhz). after initialization, the sdram devices are fully functional. figure 19-3. sdram device initialization sequence 19.7.2 sdram controller write cycle the sdramc allows burst access or single acce ss. in both cases, the sdramc keeps track of the active row in each bank, thus maximizing performance. to initiate a burst access, the sdramc uses the transfer type signal provided by the master requesting the access. if the next access is a sequential write a ccess, writing to the sdram devi ce is carried out. if the next access is a write-sequential access, but the current access is to a boundary page, or if the next access is in another row, then the sdramc generates a precharge command, activates the new row and initiates a write co mmand. to comply with sdram timing parameters, additional clock cycles are inserted between precharge and active (t rp ) commands and between active and write (t rcd ) commands. for definition of these timing parameters, refer to the section 19.8.3 . this is described in figure 19-4 on page 354 . sdcke sdck sdramc_a[9:0] a10 sdramc_a[12:11] sdcs ras cas sdwe dqm inputs stable for 200 usec valid command precharge all banks 1st auto refresh 8th auto refresh lmr command t mrd t rc t rp
354 32117b?avr-03/11 at32uc3c figure 19-4. write burst, 16-bit sdram access 19.7.3 sdram controller read cycle the sdramc allows burst access, incremental bur st of unspecified length or single access. in all cases, the sdramc keeps track of the acti ve row in each bank, thus maximizing perfor- mance of the sdram. if row and bank addresse s do not match the previous row/bank address, then the sdramc automatically generates a precharge command, activates the new row and starts the read command. to comply with the sdram timing para meters, additional clock cycles on sdck are inserted between precharge and active (t rp ) commands and between active and read (t rcd ) commands. these two parameters are set in the cr register of the sdramc. after a read command, additional wait states are generated to comply with the cas latency (one, two, or three clock delays specified in the cr register). for a single access or an incremented burst of unspecified length, the sdramc anticipates the next access. while the last valu e of the column is returned by the sdramc on the bus, the sdramc anticipates the read to the next column and thus anticipates the cas latency. this reduces the effect of the cas latency on the internal bus. for burst access of specified length (4, 8, 16 words), access is not anticipated. this case leads to the best performance. if the burst is broken (border, busy mode, etc.), the next access is han- dled as an incrementing burst of unspecified length. sdcs t rcd = 3 sdck sdramc_a[12:0] ras cas sdwe d[15:0] dna dnb dnc dnd dne dnf dng dnh dni dnj dnk dnl row n col b col c col d col e col f col g col h col i col k col l col j col a
355 32117b?avr-03/11 at32uc3c figure 19-5. read burst, 16-bit sdram access 19.7.4 border management when the memory row boundary has been reached, an automatic page break is inserted. in this case, the sdramc generates a precharge command, activates the new row and initiates a read or write command. to comply with sdram timing parameters, an additional clock cycle is inserted between the precharge and active (t rp ) commands and between the active and read (t rcd ) commands. this is described in figure 19-6 on page 356 . sdcs d[15:0] (input) sdck sdramc_a[12:0] ras cas sdwe dna dnb dnc dnd dne dnf col a col b col c col d col e col f row n cas = 2 t rcd = 3
356 32117b?avr-03/11 at32uc3c figure 19-6. read burst with boundary row access 19.7.5 sdram controller refresh cycles an auto refresh command is used to refresh the sdram device. refresh addresses are gener- ated internally by the sdram device and incr emented after each auto refresh automatically. the sdramc generates these auto refresh commands periodically. an internal timer is loaded with the value in the refresh timer register (tr) that indicates the number of clock cycles between successive refresh cycles. a refresh error interrupt is generated when the previous auto refresh command did not perform. in this case a refresh error status bit is set in the interrupt status register (isr.res). it is cleared by reading the isr register. when the sdramc initiates a refresh of the sdram device, internal memory accesses are not delayed. however, if the cpu tr ies to access the sdram, the slave indicates that the device is busy and the master is held by a wait signal. see figure 19-7 on page 357 . sdcs sdck sdramc_a[12:0] cas ras sdwe d[15:0] dna dnb dnc dnd dma dmb dmc dme dmd row m col a col b col c col d col e row n col a col b col c col d cas = 2 t rcd = 3 t rp = 3
357 32117b?avr-03/11 at32uc3c figure 19-7. refresh cycle followed by a read access 19.7.6 power management three low power modes are available: ? self refresh mode: the sdram executes its own auto refresh cycles without control of the sdramc. current drained by the sdram is very low. ? power-down mode: auto refresh cycles are controlled by the sdramc. between auto refresh cycles, the sdram is in power-down. current drained in power-down mode is higher than in self refresh mode. ? deep power-down mode (only available with mobile sdram): the sdram contents are lost, but the sdram does not drain any current. the sdramc activates one low power mode as so on as the sdram device is not selected. it is possible to delay the entry in self refresh and power-down mode after the last access by config- uring the timeout field in the low power register (lpr.timeout). 19.7.6.1 self refresh mode this mode is selected by writing the value one to the low power configuration bits field in the sdramc low power register (l pr.lpcb). in self refresh mode, the sdram device retains data without external clocking and provides its own internal clocking, thus performing its own auto refresh cycles. all the inputs to the sdra m device become ?don?t care? except sdcke, which remains low. as soon as the sdram dev ice is selected, the sdramc provides a sequence of commands and exits self refresh mode. some low power sdrams (e.g., mobile sdram) can refresh only one quarter or a half quarter or all banks of the sdram array. this feature reduces the self refresh current. to configure this feature, temperature compensated self refresh (tcsr), partial array self refresh (pasr) sdcs sdck sdramc_a[12:0] row n col c col d ras cas sdwe d[15:0] (input) dnb dnc dnd dma col a row m cas = 2 t rcd = 3 t rc = 8 t rp = 3
358 32117b?avr-03/11 at32uc3c and drive strength (ds) parameters must be set by writing the corresponding fields in the lpr register, and transmitted to the low po wer sdram device during initialization. after initialization, as soon as the lpr.pasr, lpr.ds, or lpr.tcsr fields are modified and self refresh mode is activated, the sdramc issues an extended load mode register command to the sdram and the extended mode register of the sdram device is accessed automati- cally. the pasr/ds/tcsr parameters values are therefore updated before entry into self refresh mode. the sdram device must remain in self refresh mode for a minimum period of t ras and may remain in self refresh mode for an indefinite period. this is described in figure 19-8 on page 358 . figure 19-8. self refresh mode behavior 19.7.6.2 low power mode this mode is selected by writing the value two to the lpr.lpcb field. power consumption is greater than in self refresh mode. all the i nput and output buffers of the sdram device are deactivated except sdcke, whic h remains low. in contrast to self refresh mode, the sdram device cannot remain in low power mode longer than the refresh period (64ms for a whole device refresh operation). as no auto refresh operations are performed by the sdram itself, the sdramc carries out the refresh operation. the exit procedure is faster than in self refresh mode. this is described in figure 19-9 on page 359 . sdramc_a[12:0] sdck sdcke sdcs ras cas access request to the sdram controller self refresh mode row t xsr = 3 sdwe
359 32117b?avr-03/11 at32uc3c figure 19-9. low power mode behavior 19.7.6.3 deep power-down mode this mode is selected by writing the value three to the lpr.lpcb field. when this mode is acti- vated, all internal voltage generators inside the sdram are stopped and all data is lost. when this mode is enabled, the user must no t access to the sdram until a new initialization sequence is done (see section 19.7.1 ). this is described in figure 19-10 on page 360 . low power mode cas = 2 t rcd = 3 sdcs sdck sdramc_a[12:0] ras cas sdcke d[15:0] (input) dna dnb dnc dnd dne dnf col f col e col d col c col b col a row n
360 32117b?avr-03/11 at32uc3c figure 19-10. deep power-down mode behavior sdcs sdck sdramc_a[12:0] ras cas sdwe scke d[15:0] (input) dnb dnc dnd col d col c row n t rp = 3
361 32117b?avr-03/11 at32uc3c 19.8 user interface table 19-5. sdramc register memory map offset register register name access reset 0x00 mode register mr read/write 0x00000000 0x04 refresh timer register tr read/write 0x00000000 0x08 configuration register cr read/write 0x852372c0 0x0c high speed register hsr read/write 0x00000000 0x10 low power register lpr read/write 0x00000000 0x14 interrupt enable register ier write-only 0x00000000 0x18 interrupt disable register idr write-only 0x00000000 0x1c interrupt mask register imr read-only 0x00000000 0x20 interrupt status register isr read-only 0x00000000 0x24 memory device register mdr read/write 0x00000000 0xfc version register version read-only - (1) 1. the reset values for these fields are de vice specific. please refer to the module conf iguration section at the end of this ch ap- ter.
362 32117b?avr-03/11 at32uc3c 19.8.1 mode register register name :mr access type : read/write offset: 0x00 reset value : 0x00000000 ? mode: command mode this field defines the command issued by t he sdramc when the sdram device is accessed. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ----- mode mode description 0 normal mode. any access to the sdram is decoded normally. 1 the sdramc issues a ?nop? command when the sdram device is accessed regardless of the cycle. 2 the sdramc issues an ?all banks precharge? command when the sdram device is accessed regardless of the cycle. 3 the sdramc issues a ?load mode register? command wh en the sdram device is accessed regardless of the cycle. this command will load the cr.c as field into the sdram device mode register. all the other parameters of the sdram device mode register will be set to zero (burst length, burst type, operating mode, write burst mode...). 4 the sdramc issues an ?auto refres h? command when the sdram device is accessed regardless of the cycle. previously, an ?all banks precharge? command must be issued. 5 the sdramc issues an ?extended load mode register? command when the sdram device is accessed regardless of the cycle. this command will load the lpr.pasr, lpr.ds, and lpr.tcr fields into the sdram device extended mode register. all the other bits of th e sdram device extended mode register will be set to zero. 6 deep power-down mode. enters deep power-down mode.
363 32117b?avr-03/11 at32uc3c 19.8.2 refresh timer register register name :tr access type : read/write offset: 0x04 reset value : 0x00000000 ? count[11:0]: refresh timer count this 12-bit field is loaded into a timer that generates the refres h pulse. each time the refresh pulse is generated, a refresh burst is initiated. the value to be loaded depends on the sdramc clock frequency (clk_sdramc), the refresh rate of the sdram device and the refresh burst length where 15.6s per row is a typical value for a burst of length one. to refresh the sdram device, this 12-bit fiel d must be written. if this condition is not satisfied, no refresh command is issue d and no refresh of the sdram device is carried out. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - count[11:8] 76543210 count[7:0]
364 32117b?avr-03/11 at32uc3c 19.8.3 configuration register register name :cr access type : read/write offset: 0x08 reset value : 0x852372c0 ? txsr: exit self refr esh to active delay reset value is eight cycles. this field defines the delay between scke set high and an activate command in number of cycles. number of cycles is between 0 and 15. ? tras: active to precharge delay reset value is five cycles. this field defi nes the delay between an activate co mmand and a precharge command in numb er of cycles. number of cycles is between 0 and 15. ? trcd: row to column delay reset value is two cycles. this field defines the delay between an activate command and a r ead/write command in number of cycles. number of cycles is between 0 and 15. ? trp: row precharge delay reset value is three cycles. this field defines the delay between a pr echarge command and another command in number of cycles. number of cycles is between 0 and 15. ? trc: row cycle delay reset value is seven cycles. this field defines the delay between a refresh and an activate co mmand in number of cycles. number of cycles is between 0 and 15. ? twr: write recovery delay reset value is two cycles. this field defines the write recovery time in number of cycles. number of cycles is between 0 and 15. ? dbw: data bus width reset value is 16 bits. 0: reserved. 1: data bus width is 16 bits. 31 30 29 28 27 26 25 24 txsr tras 23 22 21 20 19 18 17 16 trcd trp 15 14 13 12 11 10 9 8 trc twr 76543210 dbw cas nb nr nc
365 32117b?avr-03/11 at32uc3c ? cas: cas latency reset value is two cycles. in the sdramc, only a cas latency of one, two and three cycles is managed. ? nb: number of banks reset value is two banks. ? nr: number of row bits reset value is 11 row bits. ? nc: number of column bits reset value is 8 column bits. cas cas latency (cycles) 0reserved 11 22 33 nb number of banks 02 14 nr row bits 011 112 213 3reserved nc column bits 08 19 210 311
366 32117b?avr-03/11 at32uc3c 19.8.4 high speed register register name :hsr access type : read/write offset: 0x0c reset value: 0x00000000 ? da: decode cycle enable a decode cycle can be added on the addre sses as soon as a non-sequential access is performed on the hsb bus. the addition of the dec ode cycle allows the sdra mc to gain time to a ccess the sdram memory. 1: decode cycle is enabled. 0: decode cycle is disabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------da
367 32117b?avr-03/11 at32uc3c 19.8.5 low power register register name :lpr access type : read/write offset: 0x10 reset value : 0x00000000 ? timeout: time to define when low power mode is enabled ? ds: drive strength (only for low power sdram) this field is transmitted to the sdram during initialization to se lect the sdram strength of data output. this parameter must b e set according to the sdram device specification. after initialization, as soon as this field is modified and self refresh mode is activated, t he extended mode register of the sdram device is accessed automatically and its ds parameter value is updated before entry in self refresh mode. ? tcsr: temperature compensated self refresh (only for low power sdram) this field is transmitted to the sdram during initialization to set the refresh interval during self refresh mode depending on the temperature of the low power sdram. this parameter must be set according to the sdram device specification. after initialization, as soon as this field is modified and self refresh mode is activated, t he extended mode register of the sdram device is accessed autom atically and its tcsr parameter value is u pdated before entry in self refresh mode. ? pasr: partial array self refresh (only for low power sdram) this field is transmitted to the sdram during initialization to sp ecify whether only one quarter, one half or all banks of the sdram array are enabled. disabled banks are not refreshed in self refresh mode. this parameter must be set according to the sdram device specification. after initialization, as soon as this field is modified and self refresh mode is activated, t he extended mode register of the sdram device is accessed autom atically and its pasr parameter value is u pdated before entry in self refresh mode. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -- timeout ds tcsr 76543210 - pasr - - lpcb timeout time to define when low power mode is enabled 0 the sdramc activates the sdram low power mode i mmediately after the end of the last transfer. 1 the sdramc activates the sdram low power mode 64 clock cycles after the end of the last transfer. 2 the sdramc activates the sdram low power mode 128 clock cycles after the end of the last transfer. 3 reserved.
368 32117b?avr-03/11 at32uc3c ? lpcb: low power configuration bits lpcb low power configuration 0 low power feature is inhibited: no power-down, self refresh or deep power-down command is issued to the sdram device. 1 the sdramc issues a self refresh command to the sdram device, the sdclk clock is deactivated and the sdcke signal is set low. the sdram device leaves the self refresh mode when accessed and enters it after the access. 2 the sdramc issues a power-down command to the sdram device after each access, the sdcke signal is set to low. the sdram device leaves the power-down mode when accessed and enters it after the access. 3 the sdramc issues a deep power-down command to the sdram device. this mode is unique to low- power sdram.
369 32117b?avr-03/11 at32uc3c 19.8.6 interrupt enable register register name :ier access type : write-only offset: 0x14 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------res
370 32117b?avr-03/11 at32uc3c 19.8.7 interrupt disable register register name :idr access type : write-only offset: 0x18 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------res
371 32117b?avr-03/11 at32uc3c 19.8.8 interrupt mask register register name :imr access type : read-only offset: 0x1c reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------res
372 32117b?avr-03/11 at32uc3c 19.8.9 interrupt status register register name :isr access type : read-only offset: 0x20 reset value: 0x00000000 ? res: refresh error status this bit is set when a refresh error is detected. this bit is cleared when the register is read. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------res
373 32117b?avr-03/11 at32uc3c 19.8.10 memory device register register name :mdr access type : read/write offset: 0x24 reset value: 0x00000000 ? md: memory device type 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------ md md device type 0 sdram 1 low power sdram other reserved
374 32117b?avr-03/11 at32uc3c 19.8.11 version register register name : version access type : read-only offset: 0xfc reset value: - ? variant: variant number reserved. no functi onality associated. ? version: version number version number of the module.no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version 76543210 version
375 32117b?avr-03/11 at32uc3c 20. peripheral dma controller (pdca) rev: 1.2.3.1 20.1 features ? multiple channels ? generates transfers between memories and peripherals such as usart and spi ? two address pointers/counters per ch annel allowing double buffering ? performance monitors to measure average and maximum transfer latency ? optional synchronizing of data transfers with extenal peripheral events ? ring buffer functionality 20.2 overview the peripheral dma controller (pdca) transfers data between on-chip peripheral modules such as usart, spi and memories (those memories ma y be on- and off-chip memories). using the pdca avoids cpu intervention for data transfers, improving the performance of the microcon- troller. the pdca can transfer data from memory to a peripheral or from a peripheral to memory. the pdca consists of multiple dma channels. each channel has: ? a peripheral select register ? a 32-bit memory pointer ? a 16-bit transfer counter ? a 32-bit memory pointer reload value ? a 16-bit transfer counter reload value the pdca communicates with the peripheral modules over a set of handshake interfaces. the peripheral signals the pdca when it is ready to receive or transmit data. the pdca acknowl- edges the request when the transmission has started. when a transmit buffer is empty or a receive buffer is full, an optional interrupt request can be generated.
376 32117b?avr-03/11 at32uc3c 20.3 block diagram figure 20-1. pdca block diagram 20.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 20.4.1 power management if the cpu enters a sleep mode that disables the pdca clocks, the pdca will stop functioning and resume operation after the system wakes up from sleep mode. 20.4.2 clocks the pdca has two bus clocks connected: one high speed bus clock (clk_pdca_hsb) and one peripheral bus clock (clk_pdca_pb). thes e clocks are generated by the power man- ager. both clocks are enabled at reset, and can be disabled by wr iting to the power manager. it is recommended to disable the pdca before disa bling the clocks, to avoid freezing the pdca in an undefined state. 20.4.3 interrupts the pdca interrupt request lines are connected to the interrupt controller. using the pdca interrupts requires the interrupt controller to be programmed first. hsb to pb bridge peripheral dma controller (pdca) peripheral 0 high speed bus matrix handshake interfaces peripheral bus irq hsb hsb interrupt controller peripheral 1 peripheral 2 peripheral (n-1) ... memory hsb
377 32117b?avr-03/11 at32uc3c 20.4.4 peripheral events the pdca peripheral events are connected via the peripheral event system. refer to the peripheral event system chapter for details. 20.5 functional description 20.5.1 basic operation the pdca consists of multiple independent pdca channels, each capable of handling dma requests in parallel. each pdca channels contains a set of configuration registers which must be configured to start a dma transfer. in this section the steps necessary to configure one pdca channel is outlined. the peripheral to transfer data to or from must be configured correctly in the peripheral select register (psr). this is performed by writing the peripheral identity (pid) value for the corre- sponding peripheral to the pid field in the ps r register. the pid also encodes the transfer direction, i.e. memory to peripheral or peripheral to memory. see section 20.5.6 . the transfer size must be written to the transfer size field in the mode register (mr.size). the size must match the data size produced or consumed by the selected peripheral. see section 20.5.7 . the memory address to transfer to or from, depending on the psr, must be written to the mem- ory address register (mar). for each transfer the memory address is increased by either a one, two or four, depending on the size set in mr. see section 20.5.2 . the number of data items to transfer is written to the tcr register. if the pdca channel is enabled, a transfer will start imm ediately after writing a non-zero value to tc r or the reload ver- sion of tcr, tcrr. after each transfer the tcr value is decreased by one. both mar and tcr can be read while the pdca channel is active to monitor the dma progress. see section 20.5.3 . the channel must be enabled for a transfer to start. a channel is enable by writing a one to the en bit in the control register (cr). 20.5.2 memory pointer each channel has a 32-bit memory address regi ster (mar). this register holds the memory address for the next transfer to be performed. the register is automatically updated after each transfer. the address will be increa sed by either one, two or four depending on the size of the dma transfer (byte, halfword or word). the mar can be read at any time during transfer. 20.5.3 transfer counter each channel has a 16-bit transfer counter register (tcr). this register must be programmed with the number of transfers to be performed. the tcr register should contain the number of data items to be transferred independently of the transfer size. the tcr can be read at any time during transfer to see the number of remaining transfers. 20.5.4 reload registers both the mar and the tcr have a reload regist er, respectively memory address reload regis- ter (marr) and transfer counter reload register (tcrr). these registers provide the possibility for the pdca to work on two memory buffer s for each channel. when one buffer has completed, mar and tcr will be re loaded with the values in marr and tcrr. the reload logic is always enabled and will trigger if the tcr reaches zero while tcrr holds a non-zero value. after reload, the marr and tcrr registers are cleared.
378 32117b?avr-03/11 at32uc3c if tcr is zero when writing to tcrr, the tcr and mar are automatically updated with the value written in tcrr and marr. 20.5.5 ring buffer when ring buffer mode is enabled the tcrr and marr regi sters will not be cleared when tcr and mar registers reload. th is allows the pdca to read or write to the same memory region over and over again until the transfer is actively stopped by the user. ring buffer mode is enabled by writing a one to the ring buffer bit in the mode register (mr.ring). 20.5.6 peripheral selection the peripheral select register (psr) decides which peripheral should be connected to the pdca channel. a peripheral is selected by writing the corresponding peripheral identity (pid) to the pid field in the psr register. writing the pid will both select the direction of the transfer (memory to peripheral or peripheral to memory ), which handshake interface to use, and the address of the peripheral holding register. refer to the peripheral identity (pid) table in the mod- ule configuration section for the peripheral pid values. 20.5.7 transfer size the transfer size can be set individually for each channel to be either byte, halfword or word (8- bit, 16-bit or 32-bit respectively). transfer size is set by writing the desired value to the transfer size field in the mode register (mr.size). when the pdca moves data between peripherals and memory, data is automatically sized and aligned. when memory is accessed, the size specified in mr.size and system alignment is used. when a peripheral register is accessed t he data to be transferred is converted to a word where bit n in the data corresponds to bit n in the peripheral register. if the transfer size is byte or halfword, bits greater than 8 and16 respectively are set to zero. refer to the module configuration section for information regarding what peripheral registers are used for the different peripherals and then to the peripheral specific chapter for information about the size option available for the different registers. 20.5.8 enabling and disabling each dma channel is enabled by writing a one to the transfer enable bit in the control register (cr.ten) and disabled by writing a one to the transfer disable bit (cr.tdis). the current sta- tus can be read from the status register (sr). while the pdca channel is enabled all dma re quest will be handled as long the tcr and tcrr is not zero. 20.5.9 interrupts interrupts can be enabled by writing a one to the corresponding bit in the interrupt enable regis- ter (ier) and disabled by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt mask register (imr) can be read to see whether an interrupt is enabled or not. the current status of an interrupt source can be read through the interrupt status register (isr). the pdca has three interrupt sources: ? reload counter zero - the tcrr register is zero. ? transfer finished - both the tcr and tcrr registers are zero. ? transfer error - an error has occurred in accessing memory.
379 32117b?avr-03/11 at32uc3c 20.5.10 priority if more than one pdca channel is requesting transfer at a given time, the pdca channels are prioritized by their channel number. channels wi th lower numbers have priority over channels with higher numbers, giving channel zero the highest priority. 20.5.11 error handling if the memory address register (mar) is set to point to an invalid location in memory, an error will occur when the pdca tries to perform a transfer. when an error occurs, the transfer error bit in the interrup t status register (isr.terr) will be se t and the dma channel that caused the error will be stopped. in order to restart the channel, the user must program the memory address register to a valid address and then write a one to the error clear bit in the control register (cr.eclr). if the transfer error interrupt is enabled , an interrupt request will be gener- ated when an transfer error occurs. 20.5.12 peripheral event trigger peripheral events can be used to trigger pdca channel transfers. peripheral event synchroniza- tions are enabled by writing a one to the event trigger bit in the mode register (mr.etrig). when set, all dma requests will be blocked until an peripheral event is received. for each peripheral event received, only one data item is transferred. if no dma requests are pending when a peripheral event is received, the pdca w ill start a transfer as so on as a peripheral event is detected. if multiple events arrive while the pdca channel is busy transferring data, an over- flow condition will be signaled in the peripheral event system. refer to the peripheral event system chapter for more information. 20.6 performance monitors up tp two performance monitors allow the user to measure the activity and stall cycles for pdca transfers. to monitor a pdca channel, the corresponding channel number must be written to one of the monnch fields in the performance control register (pcontrol) and a one must be written to the corresponding chnen bit in the same register. due to performance monitor hardware resource sharing, the two monitor channels should not be programmed to monitor the same pdca channel. this may result in undefined perfor- mance monitor behavior. 20.6.1 measuring mechanisms three different parameters can be measured by each channel: ? the number of data transfer cycles since last channel reset, both for read and write ? the number of stall cycles since last channel reset, both for read and write ? the maximum latency since last channel reset, both for read and write these measurements can be extracted by soft ware and used to generate indicators for bus latency, bus load, and maximum bus latency. each of the counters has a fixed width, and may therefore overflow. when an overflow is encountered in either the performance channel data read/write cycle registers (prdatan and pwdatan) or the performance channel read/write stall cycles registers (prstalln and pwstalln) of a channel, all registers in the channel are reset. this behavior is altered if the channel overflow freeze bit is one in the performance control register (pcontrol.chnovf). if this bit is one, the channel registers are fr ozen when either data or stall reaches its maxi- mum value. this simplifies one-shot readout of the counter values.
380 32117b?avr-03/11 at32uc3c the registers can also be manually reset by writing a one to the channel reset bit in the pcon- trol register (pcontrol.chnres). the performance channel read/write latency registers (prlatn and pwlatn) are saturating when their maximum count value is reached. the prlatn and pwlatn registers are rese t only by writing a one to the chnres in pcontrol. a counter must manually be enabled by writing a one to the channel enable bit in the perfor- mance control register (pcontrol.chnen).
381 32117b?avr-03/11 at32uc3c 20.7 user interface 20.7.1 memory map overview the channels are mapped as shown in table 20-1 . each channel has a set of configuration reg- isters, shown in table 20-2 , where n is the channel number. 20.7.2 channel memory map note: 1. the reset values are device specific. please refer to the module config uration section at the end of this chapter. table 20-1. pdca register memory map address range contents 0x000 - 0x03f dma channel 0 configuration registers 0x040 - 0x07f dma channel 1 configuration registers ... ... (0x000 - 0x03f)+m*0x040 dma channel m configuration registers 0x800-0x830 performance monitor registers 0x834 version register table 20-2. pdca channel configuration registers offset register register name access reset 0x000 + n*0x040 memory address register mar read/write 0x00000000 0x004 + n*0x040 peripheral select register psr read/write - (1) 0x008 + n*0x040 transfer counter register tcr read/write 0x00000000 0x00c + n*0x040 memory address reload register marr read/write 0x00000000 0x010 + n*0x040 transfer counter reload register tcrr read/write 0x00000000 0x014 + n*0x040 control register cr write-only 0x00000000 0x018 + n*0x040 mode register mr read/write 0x00000000 0x01c + n*0x040 status register sr read-only 0x00000000 0x020 + n*0x040 interrupt enable register ier write-only 0x00000000 0x024 + n*0x040 interrupt disable register idr write-only 0x00000000 0x028 + n*0x040 interrupt mask register imr read-only 0x00000000 0x02c + n*0x040 interrupt status register isr read-only 0x00000000
382 32117b?avr-03/11 at32uc3c 20.7.3 performance monitor memory map note: 1. the number of performance monitors is device specific. if the device has only one perfor- mance monitor, the channel1 r egisters are not available. please refer to the module configuration section at the end of this chapter for the number of performance monitors on this device. 20.7.4 version register memory map note: 1. the reset values are device specific. please refer to the module configuration section at the end of this chapter. table 20-3. pdca performance monitor registers (1) offset register register name access reset 0x800 performance control register pcontrol read/write 0x00000000 0x804 channel0 read data cycles prdata0 read-only 0x00000000 0x808 channel0 read stall cycles prstall0 read-only 0x00000000 0x80c channel0 read max latency prlat0 read-only 0x00000000 0x810 channel0 write data cycles pwdata0 read-only 0x00000000 0x814 channel0 write stall cycles pwstall0 read-only 0x00000000 0x818 channel0 write max latency pwlat0 read-only 0x00000000 0x81c channel1 read data cycles prdata1 read-only 0x00000000 0x820 channel1 read stall cycles prstall1 read-only 0x00000000 0x824 channel1 read max latency prlat1 read-only 0x00000000 0x828 channel1 write data cycles pwdata1 read-only 0x00000000 0x82c channel1 write stall cycles pwstall1 read-only 0x00000000 0x830 channel1 write max latency pwlat1 read-only 0x00000000 table 20-4. pdca version register memory map offset register register name access reset 0x834 version register version read-only - (1)
383 32117b?avr-03/11 at32uc3c 20.7.5 memory address register name: mar access type: read/write offset: 0x000 + n*0x040 reset value: 0x00000000 ? maddr: memory address address of memory buffer. maddr should be programmed to poin t to the start of the memory buffer when configuring the pdca. during transfer, maddr will point to the next memory location to be read/written. 31 30 29 28 27 26 25 24 maddr[31:24] 23 22 21 20 19 18 17 16 maddr[23:16] 15 14 13 12 11 10 9 8 maddr[15:8] 76543210 maddr[7:0]
384 32117b?avr-03/11 at32uc3c 20.7.6 peripheral select register name: psr access type: read/write offset: 0x004 + n*0x040 reset value: - ? pid: peripheral identifier the peripheral identifier selects which peripheral should be con nected to the dma channel. writ ing a pid will select both which handshake interface to use, the direction of the transfer and also the address of the receive/transfer holding register for the peripheral. see the module configuration section of pdca for details. the width of the pid field is device specific and dependent on the number of peripheral modules in the device. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 pid
385 32117b?avr-03/11 at32uc3c 20.7.7 transfer counter register name: tcr access type: read/write offset: 0x008 + n*0x040 reset value: 0x00000000 ? tcv: transfer counter value number of data items to be transferred by the pdca. tcv must be programmed with the total number of transfers to be made. during transfer, tcv contains the number of remaining transfers to be done. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 tcv[15:8] 76543210 tcv[7:0]
386 32117b?avr-03/11 at32uc3c 20.7.8 memory address reload register name: marr access type: read/write offset: 0x00c + n*0x040 reset value: 0x00000000 ? marv: memory address reload value reload value for the mar register. this value will be loaded in to mar when tcr reaches zero if the tcrr register has a non- zero value. 31 30 29 28 27 26 25 24 marv[31:24] 23 22 21 20 19 18 17 16 marv[23:16] 15 14 13 12 11 10 9 8 marv[15:8] 76543210 marv[7:0]
387 32117b?avr-03/11 at32uc3c 20.7.9 transfer counter reload register name: tcrr access type: read/write offset: 0x010 + n*0x040 reset value: 0x00000000 ? tcrv: transfer counter reload value reload value for the tcr register. when tcr reaches zero, it will be reloaded with tcrv if tcrv has a positive value. if tcrv is zero, no more transfers will be performed for the chann el. when tcr is reloaded, the tcrr register is cleared. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 tcrv[15:8] 76543210 tcrv[7:0]
388 32117b?avr-03/11 at32uc3c 20.7.10 control register name: cr access type: write-only offset: 0x014 + n*0x040 reset value: 0x00000000 ? eclr: transfer error clear writing a zero to this bit has no effect. writing a one to this bit will clear the transfer error bit in the status register (sr.terr). clearing the sr.terr bit will all ow the channel to transmit data. the memory address must first be set to point to a valid location. ? tdis: transfer disable writing a zero to this bit has no effect. writing a one to this bit will disable transfer for the dma channel. ? ten: transfer enable writing a zero to this bit has no effect. writing a one to this bit will enable transfer for the dma channel. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------eclr 76543210 ------tdisten
389 32117b?avr-03/11 at32uc3c 20.7.11 mode register name: mr access type: read/write offset: 0x018 + n*0x040 reset value: 0x00000000 ? ring: ring buffer 0:the ring buffer functionality is disabled. 1:the ring buffer functionality is enabled. when enabled, the reload registers, marr and tcrr will not be cleared after reload. ? etrig: event trigger 0:start transfer when the peripheral selected in periph eral select register (psr) requests a transfer. 1:start transfer only when or after a peripheral event is received. ? size: size of transfer 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - ring etrig size table 20-5. size of transfer size size of transfer 0 byte 1 halfword 2word 3 reserved
390 32117b?avr-03/11 at32uc3c 20.7.12 status register name: sr access type: read-only offset: 0x01c + n*0x040 reset value: 0x00000000 ? ten: transfer enabled this bit is cleared when the tdis bit in cr is written to one. this bit is set when the ten bit in cr is written to one. 0: transfer is disabled for the dma channel. 1: transfer is enabled for the dma channel. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------ten
391 32117b?avr-03/11 at32uc3c 20.7.13 interrupt enable register name: ier access type: write-only offset: 0x020 + n*0x040 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - terr trc rcz
392 32117b?avr-03/11 at32uc3c 20.7.14 interrupt disable register name: idr access type: write-only offset: 0x024 + n*0x040 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - terr trc rcz
393 32117b?avr-03/11 at32uc3c 20.7.15 interrupt mask register name: imr access type: read-only offset: 0x028 + n*0x040 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - terr trc rcz
394 32117b?avr-03/11 at32uc3c 20.7.16 interrupt status register name: isr access type: read-only offset: 0x02c + n*0x040 reset value: 0x00000000 ? terr: transfer error this bit is cleared when no transfer errors ha ve occurred since the last write to cr.eclr. this bit is set when one or more transfer errors has occurred since reset or the last write to cr.eclr. ? trc: transfer complete this bit is cleared when the tcr and/or the tcrr holds a non-zero value. this bit is set when both the tcr and the tcrr are zero. ? rcz: reload counter zero this bit is cleared when the tcrr holds a non-zero value. this bit is set when tcrr is zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - terr trc rcz
395 32117b?avr-03/11 at32uc3c 20.7.17 performance control register name: pcontrol access type: read/write offset: 0x800 reset value: 0x00000000 ? mon1ch: performance monitor channel 1 ? mon0ch: performance monitor channel 0 the pdca channel number to monitor with counter n due to performance monitor hardware resour ce sharing, the two performance monitor channels should not be programmed to monitor the same pdca channel. this may result in undefined monitor behavior. ? ch1res: performance channel 1 counter reset writing a zero to this bit has no effect. writing a one to this bit will reset the counter in performance channel 1. this bit always reads as zero. ? ch0res: performance channel 0 counter reset writing a zero to this bit has no effect. writing a one to this bit will reset the counter in performance channel 0. this bit always reads as zero. ? ch1of: performance channel 1 overflow freeze 0: the performance channel registers are reset if data or stall overflows. 1: all performance channel registers are frozen just before data or stall overflows. ? ch1of: performance channel 0 overflow freeze 0: the performance channel registers are reset if data or stall overflows. 1: all performance channel registers are frozen just before data or stall overflows. ? ch1en: performance channel 1 enable 0: performance channel 1 is disabled. 1: performance channel 1 is enabled. ? ch0en: performance channel 0 enable 0: performance channel 0 is disabled. 1: performance channel 0 is enabled. 31 30 29 28 27 26 25 24 -- mon1ch 23 22 21 20 19 18 17 16 -- mon0ch 15 14 13 12 11 10 9 8 ------ch1resch0res 76543210 - - ch1of ch0of - - ch1en ch0en
396 32117b?avr-03/11 at32uc3c 20.7.18 performance channel 0 read data cycles name: prdata0 access type: read-only offset: 0x804 reset value: 0x00000000 ? data: data cycles counted since last reset clock cycles are counted us ing the clk_pdca_hsb clock 31 30 29 28 27 26 25 24 data[31:24] 23 22 21 20 19 18 17 16 data[23:16] 15 14 13 12 11 10 9 8 data[15:8] 76543210 data[7:0]
397 32117b?avr-03/11 at32uc3c 20.7.19 performance channel 0 read stall cycles name: prstall0 access type: read-only offset: 0x808 reset value: 0x00000000 ? stall: stall cycles counted since last reset clock cycles are counted us ing the clk_pdca_hsb clock 31 30 29 28 27 26 25 24 stall[31:24] 23 22 21 20 19 18 17 16 stall[23:16] 15 14 13 12 11 10 9 8 stall[15:8] 76543210 stall[7:0]
398 32117b?avr-03/11 at32uc3c 20.7.20 performance channel 0 read max latency name: prlat0 access type: read/write offset : 0x80c reset value: 0x00000000 ? lat: maximum transfer initiation cycles counted since last reset clock cycles are counted us ing the clk_pdca_hsb clock this counter is saturating. the register is reset only when pcontrol.ch0res is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 lat[15:8] 76543210 lat[7:0]
399 32117b?avr-03/11 at32uc3c 20.7.21 performance channel 0 write data cycles name: pwdata0 access type: read-only offset: 0x810 reset value: 0x00000000 ? data: data cycles counted since last reset clock cycles are counted us ing the clk_pdca_hsb clock 31 30 29 28 27 26 25 24 data[31:24] 23 22 21 20 19 18 17 16 data[23:16] 15 14 13 12 11 10 9 8 data[15:8] 76543210 data[7:0]
400 32117b?avr-03/11 at32uc3c 20.7.22 performance channel 0 write stall cycles name: pwstall0 access type: read-only offset: 0x814 reset value: 0x00000000 ? stall: stall cycles counted since last reset clock cycles are counted us ing the clk_pdca_hsb clock 31 30 29 28 27 26 25 24 stall[31:24] 23 22 21 20 19 18 17 16 stall[23:16] 15 14 13 12 11 10 9 8 stall[15:8] 76543210 stall[7:0]
401 32117b?avr-03/11 at32uc3c 20.7.23 performance channel 0 write max latency name: pwlat0 access type: read/write offset : 0x818 reset value: 0x00000000 ? lat: maximum transfer initiation cycles counted since last reset clock cycles are counted us ing the clk_pdca_hsb clock this counter is saturating. the register is reset only when pcontrol.ch0res is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 lat[15:8] 76543210 lat[7:0]
402 32117b?avr-03/11 at32uc3c 20.7.24 performance channel 1 read data cycles name: prdata1 access type: read-only offset: 0x81c reset value: 0x00000000 ? data: data cycles counted since last reset clock cycles are counted us ing the clk_pdca_hsb clock 31 30 29 28 27 26 25 24 data[31:24] 23 22 21 20 19 18 17 16 data[23:16] 15 14 13 12 11 10 9 8 data[15:8] 76543210 data[7:0]
403 32117b?avr-03/11 at32uc3c 20.7.25 performance channel 1 read stall cycles name: prstall1 access type: read-only offset: 0x820 reset value: 0x00000000 ? stall: stall cycles counted since last reset clock cycles are counted us ing the clk_pdca_hsb clock 31 30 29 28 27 26 25 24 stall[31:24] 23 22 21 20 19 18 17 16 stall[23:16] 15 14 13 12 11 10 9 8 stall[15:8] 76543210 stall[7:0]
404 32117b?avr-03/11 at32uc3c 20.7.26 performance channel 1 read max latency name: platr1 access type: read/write offset : 0x824 reset value: 0x00000000 ? lat: maximum transfer initiation cycles counted since last reset clock cycles are counted us ing the clk_pdca_hsb clock this counter is saturating. the register is reset only when pcontrol.ch1res is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 lat[15:8] 76543210 lat[7:0]
405 32117b?avr-03/11 at32uc3c 20.7.27 performance channel 1 write data cycles name: pwdata1 access type: read-only offset: 0x828 reset value: 0x00000000 ? data: data cycles counted since last reset clock cycles are counted us ing the clk_pdca_hsb clock 31 30 29 28 27 26 25 24 data[31:24] 23 22 21 20 19 18 17 16 data[23:16] 15 14 13 12 11 10 9 8 data[15:8] 76543210 data[7:0]
406 32117b?avr-03/11 at32uc3c 20.7.28 performance channel 1 write stall cycles name: pwstall1 access type: read-only offset: 0x82c reset value: 0x00000000 ? stall: stall cycles counted since last reset clock cycles are counted us ing the clk_pdca_hsb clock 31 30 29 28 27 26 25 24 stall[31:24] 23 22 21 20 19 18 17 16 stall[23:16] 15 14 13 12 11 10 9 8 stall[15:8] 76543210 stall[7:0]
407 32117b?avr-03/11 at32uc3c 20.7.29 performance channel 1 write max latency name: pwlat1 access type: read/write offset : 0x830 reset value: 0x00000000 ? lat: maximum transfer initiation cycles counted since last reset clock cycles are counted us ing the clk_pdca_hsb clock this counter is saturating. the register is reset only when pcontrol.ch1res is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 lat[15:8] 76543210 lat[7:0]
408 32117b?avr-03/11 at32uc3c 20.7.30 pdca version register name: version access type: read-only offset: 0x834 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
409 32117b?avr-03/11 at32uc3c 20.8 module configuration the specific configuration for the pdca in stance is listed in the following tables. the table below defines the valid peripheral ident ifiers (pids). the dire ction is specified as observed from the memory, so rx means transfers from peripheral to memory and tx means from memory to peripheral. table 20-6. pdca configuration features pdca number of channels 16 number of performance monitors 1 table 20-7. module clock name module name clock name description pdca clk_pdca_hsb hsb clock clk_pdca_pb peripheral bus clock from the pbc clock domain table 20-8. register reset values register reset value psrn n version 0x123 table 20-9. peripheral identity values pid direction peripheral in stance peripheral register 0 rx adcifa lcv0 1 rx adcifa lcv1 2 rx usart0 rhr 3 rx usart1 rhr 4 rx usart2 rhr 5 rx usart3 rhr 6 rx twim0 rhr 7 rx twim1 rhr 8 rx twis0 rhr 9 rx twis1 rhr 10 rx spi0 rdr 11 rx spi1 rdr 12 rx aw rhr 13 tx usart0 thr 14 tx usart1 thr 15 tx usart2 thr 16 tx usart3 thr
410 32117b?avr-03/11 at32uc3c 17 tx twim0 thr 18 tx twim1 thr 19 tx twis0 thr 20 tx twis1 thr 21 tx spi0 tdr 22 tx spi1 tdr 23 tx dacifb0 dr0 24 tx dacifb0 dr1 25 tx dacifb1 dr0 26 tx dacifb1 dr1 27 tx pwm pwm pdca register 28 tx aw thr 31 rx usart4 rhr 32 rx twim2 rhr 33 rx twis2 rhr 34 tx usart4 thr 35 tx twim2 thr 36 tx twis2 thr [44:37] rx iisc rhr [52:45] tx iisc thr table 20-9. peripheral identity values pid direction peripheral in stance peripheral register
411 32117b?avr-03/11 at32uc3c 21. memory dma controller (mdma) rev 1.0.1.1 21.1 features ? 1-4 dma channels, depending on implementation ? chained (descriptor-list controlled) or unchained (single) transfers ? descriptor read and writeback support ? descriptors are placed in circular buffers of programmable length ? programmable fixed or round-robin priority between channels ? programmable burst length (1, 4, 8, or 16-beat) ? byte/halfword/word transfers ? optional endianess-conver sion on transferred data ? interrupt on tran sfer complete 21.2 overview the purpose of the mdma is to perform memory-to-memory transfers. for peripheral-to-memory transfers, the peripheral dma controller should be used instead. the mdma has two hsb master interfaces. one interface is dedicated to reading data while the other is dedicated to writing. the mdma is configured through a peripheral bus (pb) interface. a dma transfer on a channel can be started manually by writing the mdma configuration regis- ters for that channel. this transfer mode is referred to as single transfer mode. mdma channels can also be controlled by a descr iptor list in memory. the descriptor list con- tains all information needed to control a transfer. once a transfer has been completed, the mdma automatically reads the next descriptor, and if this descrip tor is valid, starts the next dma transfer. this transfer mode is referred to descriptor mode. 21.3 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 21.3.1 power management if the cpu enters a sleep mo de that disables clocks used by the mdma, the mdma will stop functioning and resume operation after the system wakes up from sleep mode. 21.3.2 clocks the mdma has two bus clocks connected: one high speed bus clock (clk_mdma_hsb) and one peripheral bus clock (clk_mdma_pb). thes e clocks are generated by the power man- ager. both clocks are enabled at reset, and can be disabled in the power manager. the user has to ensure that clk_mdma_hsb is not turned off while performing md ma transfers. failing to do so may deadlock the hsb. 21.3.3 interrupts the mdma interrupt request lines are connected to the interrupt controller. using the mdma interrupts requires the interrupt controller to be programmed first.
412 32117b?avr-03/11 at32uc3c 21.3.4 debug operation when an external debugger forces the cpu into debug mode, the mdma continues normal operation. if the mdma is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. 21.4 functional description 21.4.1 bus interfaces the mdma has three bus interfaces, two high-speed bus interfaces for data and descriptor transfer, and one peripheral bus interface for writing control information to and reading status information from the controller. 21.4.2 transferring data once a channel (x) is selected by the arbiter, dat a of the size given by the size field in the channel control register (ccrx.size) will be transferred from consecutive addresses starting as specified in the read address register (rarx) to consecutive addresses starting as speci- fied in the write address register (warx). the number of data to be transferred is given by the transfer count field (ccrx.tcnt). the mdma will try to transfer data in bursts with burst length given by ccrx.burst. the mdma is free to use bu rsts of shorter length if this is required by the bus semantics or if tcnt is not perfectly divisible by burst. during transfers, tcnt is continuously decremented until it reaches zero, indicating that the transfer has completed. rarx and warx are not changed by hardware during transfers. data read from the bus is put into a fifo before being written to the bus. the fifo has word- sized entries, so any halfwords or bytes trans ferred from the bus will be zero-extended before being put in the fifo. words are not extended in any way. the byte swap (bswp) field in ccrx determines if any modifications are to be performed on the read data from the zero-exten- sion unit. this allows data reformatting such as endianness-conversion. figure 21-1. byte swapping the fifo inputs 21.4.3 arbitration arbitration between the channels is performed at the end of each burst. if no other channels have pending transfers, the current channel continues uninterrupted. in fixed priority mode, if a channel of higher priority is enabled when another channel is trans- ferring data, the channel of higher priority will preempt the other channel. when the preempting channel has completed, th e arbiter will grant control to the original channel so it can complete its transfer. zero- extend byte swap read data write data fifo
413 32117b?avr-03/11 at32uc3c in round-robin mode, ot her channels with transfers pending will preempt the current channel in a round-robin fash ion. this eliminates the possibility of starvation. 21.4.4 aborting transfers transfers on any channel can be gracefully aborted by writing a one to the corresponding chan- nel disable bit in the control re gister (cr.chxdis). note that in order to successfully write to chxdis, the same write operation must also write a one to the corresponding channel enable bit (cr.chxen). successfully writing to chxdis will result in both chxen and chxdis being cleared. chxen can not be cleared by simply writing a zero to it. the hardware will disable the transfer as soon as possible. since the transfer must terminate gracefully, the chxen bits may not be cleared im mediately after writing chxdis. the user could poll chxdis to check when the channel has been disabled. 21.4.5 interrupts the mdma can generate an interrupts when a channel has completed a transfer or when a dma transfer causes a bus error. interrupts are only generated if enabled in the interrupt mask regis- ter (imr). imr is read-only, but can be modified through the write-only interrupt enable register (ier) and interrupt disable regist er (idr). an interrupt is enable d by writing a one to the corre- sponding bit in the ier. an interrupt is disabled by writing a one to the corresponding bit in the idr. if an interrupt occurs, the corresponding bit in the interrupt status register (isr) is set and an interrupt request is generated. bits in isr and their corresponding interrupt request can be cleared by writing to the appropriate bits in the interrupt clear register (icr). 21.4.6 bus errors any bus errors from transfers on a channel will automatically di sable the channe l. other chan- nels will not be affected by this. an interrupt is generated if not masked by the interrupt mask register (imr). 21.5 single transfer mode the single transfer mode (stm) is the simplest transfer mode. the software programs the reg- isters controlling the channel, writ es the correct enable bit (cr. chxen), and the transfer starts. the transfer can be preempted if a channel with higher priority is enabled before the transfer completes, or if we use round-robin mode. when the transfer completes, the cr.chxen bit is automatically cleared. if the channel com- plete interrupt is enabled in imr (imr.chxc is one), an interrupt request is generated. in order to perform a transfer in stm, the following steps must be performed: 1. make sure that the channel is free by checking the cr.chxen bit, or by waiting for a transfer complete interrupt from the channel. 2. set up the read address register (rarx), write address register (warx) and chan- nel control register (ccrx) associated with the channel. 3. enable the desired interrupts by writing a one to the corresponding bits in the interrupt enable register (ier). 4. write a one to cr.chxen to start the transfer. make sure the channel mode bit (cr.chxm) for the channel is zero (channel is in single transfer mode) 5. when the transfer completes, the chxen bit is automatically cleared. if the channel complete interrupt for the channel is enabled, the corresponding bit in the interrupt sta- tus register (isr .chxc) is set.
414 32117b?avr-03/11 at32uc3c 21.6 descriptor mode the descriptor mode (dm) performs a series of single transfers. data describing the transfers to be performed are written to memory by software, forming a queue of descriptors, each descrip- tor describing a transfer to be performed. 21.6.1 setting up and using the descriptors before being able to use the descriptor mode, the channel?s descriptor start address (dsarx) register must be initialized to point to the first descriptor in the queue. thereafter, the current descriptor address register (cdarx) must be initia lized to the same value. when the cr.chxen bit is written to one, hardware will read the first descriptor in the queue, and perform the transfer described therein. when this transfer has finished, the hardware will update the descriptor associated with the transfer, clearing the v bit in the descriptor data struc- ture located in memory. thereafter, the hardware will read the next descriptor in the queue. the address of this descriptor is dependent on the l bit of the descriptor that just completed, see section 21.6.2 . if the new descriptor has its v bi t set, the tran sfer described by this descriptor will be performed. when the transfer is complete, the descriptor will be written back to memory, with the v bit cleared. thereafter, the next descr iptor will be read. this cont inues until a descriptor with a cleared v bit is read. the queue is then empty, and all transfers described in the queue have been performed. the cr.chxen bit will then be cleared, and the channel will become idle. in order to restart the channel, the descriptor pointed to by the current descriptor address reg- ister (cdarx) for the channel must be updated by writing to the appropriate memory locations. thereafter, the chxen bit must be written to one. this will cause the descriptor to be read into the mdma, and the transfer will start. 21.6.2 descriptor organization the descriptor list is implemented as a ring of descriptors placed in memory. the length of the descriptor ring is programmable; the last descriptor in the ring has its l bit set, indicating that the next element in the ring is at the address pointed to by the descriptor start address register (dsarx). each descriptor consists of four words. when a descriptor is loaded into the mdma, the first three of these words are read into the appropriate registers, while the fourth word is discarded.
415 32117b?avr-03/11 at32uc3c figure 21-2. descriptors in memory 21.6.3 adding descriptors to a list in order to add descriptors to a list, the following actions must be performed: 1. check if there are free entries in the list for the desired channel. any entry with the v bit cleared is free. if no entries are free, wait until an entry becomes free. 2. find the first free entry in the list. this can be done by scanning the descriptor list from the entry pointed to by cdarx downto the first descriptor with the v bit cleared. 3. update the free entry by writing the desired values to the correct memory locations. 4. make sure the chxm bit for the channel is one (channel is in descriptor mode), and write a one to the chxen bit. writing a one to chxen when the chxen bit is one has no effect, so the user does not need to check the state of chxen before adding descriptors to the list. 21.6.4 interrupts in descriptor mode interrupt on transfer complete and bus error can be enabled as described in section 21.4.5 . d0 rar d0 war d0 ccr unused d1 rar d1 war d1 ccr unused dn rar dn war dn ccr unused dsar growing memory addresses wrapping addresses last bit set descriptor 0 descriptor 1 descriptor n
416 32117b?avr-03/11 at32uc3c 21.7 user interface table 21-1. mdma register memory map offset register register name channel access reset 0x00 control register cr - read/write 0x00000000 0x04 interrupt enable register ier - write-only 0x00000000 0x08 interrupt disable register idr - write-only 0x00000000 0x0c interrupt mask register imr - read-only 0x00000000 0x10 interrupt status register isr - read-only 0x00000000 0x14 interrupt clear register icr - write-only 0x00000000 0x18 parameter register pr - read-only - (1) 1. the reset values for these registers are device specific. please refer to the module configuration section at the end of this chapter. note: the number of dma channels is device-specific. not all de vices will implement all four channels. these devices will not im ple- ment all user interface registers. unim plemented registers will always read as 0. 0x1c version register vr - read-only - (1) 0x20 descriptor start address 0 dsar0 0 read/write 0x00000000 0x24 descriptor start address 1 dsar1 1 read/write 0x00000000 0x28 descriptor start address 2 dsar2 2 read/write 0x00000000 0x2c descriptor start address 3 dsar3 3 read/write 0x00000000 0x30-3c reserved - - read-only 0x00000000 0x40 current descriptor address register 0 cdar0 0 read/write 0x00000000 0x44 read address register 0 rar0 0 read/write 0x00000000 0x48 write address register 0 war0 0 read/write 0x00000000 0x4c channel control register 0 ccr0 0 read/write 0x00000000 0x50 current descriptor address register 1 cdar1 1 read/write 0x00000000 0x54 read address register 1 rar1 1 read/write 0x00000000 0x58 write address register 1 war1 1 read/write 0x00000000 0x5c channel control register 1 ccr1 1 read/write 0x00000000 0x60 current descriptor address register 2 cdar2 2 read/write 0x00000000 0x64 read address register 2 rar2 2 read/write 0x00000000 0x68 write address register 2 war2 2 read/write 0x00000000 0x6c channel control register 2 ccr2 2 read/write 0x00000000 0x70 current descriptor address register 3 cdar3 3 read/write 0x00000000 0x74 read address register 3 rar3 3 read/write 0x00000000 0x78 write address register 3 war3 3 read/write 0x00000000 0x7c channel control register 3 ccr3 3 read/write 0x00000000
417 32117b?avr-03/11 at32uc3c 21.7.1 control register name: cr access type : read/write offset: 0x00 reset value: 0x000000000 ? arb: arbitration mode 0: the mdma is in fixed priority mode. 1: the mdma is in round-robin mode. ? chxdis: channel disable writing a zero to this bit has no effect. writing a one to this bit disables the mdma channel after the current transfer has completed. to avoid hazards, chxdis bits can only be changed by writing a value to cr where the corresponding chxen bit is set. this bit is automatically cleared by hardware when the corresponding channel has been disabled. ? chxm: channel mode 0: the channel is in single transfer mode. 1: the channel is in descriptor mode. to avoid hazards, chxm bits can only be changed by writing a value to cr where the corresponding chxen bit is set. ? chxen: channel enable writing a zero to this bit this bit has no effect. writing a one to this bit enables the channel for dma transfer. this bit is automatically cleared if the transfer co mpletes when the channel is in single transfer mode. this bit is automatically cleared if the transfer completes when the channel is in descriptor mode, and the next descriptor rea d in has a cleared valid bit. this bit is automatically cleared when the corresponding channel has been disabled by writing a one to chxdis. 31 30 29 28 27 26 25 24 -------arb 23 22 21 20 19 18 17 16 ----ch3disch2disch1disch0dis 15 14 13 12 11 10 9 8 ----ch3mch2mch1mch0m 76543210 ----ch3ench2ench1ench0en
418 32117b?avr-03/11 at32uc3c 21.7.2 interrupt enable register name: ier access type: write-only offset: 0x04 reset value: 0x000000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register clears the corresponding bit in interrupt mask register (imr). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----berr3berr2berr1berr0 76543210 ----ch3cch2cch1cch0c
419 32117b?avr-03/11 at32uc3c 21.7.3 interrupt disable register name: idr access type: write-only offset: 0x08 reset value: 0x000000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register sets the corresponding bit in interrupt mask register (imr). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----berr3berr2berr1berr0 76543210 ----ch3cch2cch1cch0c
420 32117b?avr-03/11 at32uc3c 21.7.4 interrupt mask register name: imr access type: read-only offset: 0x0c reset value: 0x000000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----berr3berr2berr1berr0 76543210 ----ch3cch2cch1cch0c
421 32117b?avr-03/11 at32uc3c 21.7.5 interrupt status register name: isr access type: read-only offset: 0x10 reset value: 0x000000000 ? berrx: channel bus error this bit is cleared when the corresponding bit in icr is written to one. this bit is set when the channel has encountered a bus error and has an interrupt request pending. upon receiving a bus error, the affected channel is automatically disabled. ? chxc: channel complete this bit is cleared when the corresponding bit in icr is written to one. this bit is set when the channel has completed a transfer and has an interrupt request pending. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----berr3berr2berr1berr0 76543210 ----ch3cch2cch1cch0c
422 32117b?avr-03/11 at32uc3c 21.7.6 interrupt clear register name: icr access type: write-only offset: 0x14 reset value: 0x000000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register clears the corresponding bit in isr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----berr3berr2berr1berr0 76543210 ----ch3cch2cch1cch0c
423 32117b?avr-03/11 at32uc3c 21.7.7 parameter register name: pr access type: read-only offset: 0x18 reset value: - ? burst: maximum burst size the maximum burst size that can be used is a function of the fifo size, which can be different in different devices. this field gives the largest burst size that is supported by the device. 0: single transfer 1: 4-beat burst 2: 8-beat burst 3: 16-beat burst ? chxi: channel implemented 0: the channel is not implemented in the current device, and cannot be used. 1: the channel is implemented in the current device. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------ burst 76543210 ----ch3ich2ich1ich0i
424 32117b?avr-03/11 at32uc3c 21.7.8 version register name: vr access type: read-only offset: 0x1c reset value: - ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ---- version[11:8] 76543210 version[7:0]
425 32117b?avr-03/11 at32uc3c 21.7.9 descriptor start address register x name: dsar0, dsar1, dsar2, dsar3 access type: read/write offset: 0x20, 0x24, 0x28, 0x2c reset value: 0x000000000 ? dsar: descriptor start address register the address of the first descriptor in the chain. when the hard ware has read a descriptor with the ccrx.l bit set, the next descriptor will be read from the address in dsar. must be aligned to word size. 31 30 29 28 27 26 25 24 dsar[31:24] 23 22 21 20 19 18 17 16 dsar[23:16] 15 14 13 12 11 10 9 8 dsar[15:8] 76543210 dsar[7:0]
426 32117b?avr-03/11 at32uc3c 21.7.10 current descriptor address register x name: cdar0, cdar1, cdar2, cdar3 access type: read/write offset: 0x40, 0x50, 0x60, 0x70 reset value: 0x000000000 ? cdar: current descriptor address register the memory address pointing to the currently active descriptor. th is is either the descriptor of the current access if the chan nel is enabled, or the address of the descriptor t hat will be loaded if the channel is not enabled. must be word-aligned. not used if the channel is not in descriptor mode. 31 30 29 28 27 26 25 24 cdar[31:24] 23 22 21 20 19 18 17 16 cdar[23:16] 15 14 13 12 11 10 9 8 cdar[15:8] 76543210 cdar[7:0]
427 32117b?avr-03/11 at32uc3c 21.7.11 read address register x name: rar0, rar1, rar2, rar3 access type: read/write offset: 0x44, 0x54, 0x64, 0x74 reset value: 0x000000000 ? rar: read address register the memory address that the next read access will be done from. must be aligned according to the transfer size. 31 30 29 28 27 26 25 24 rar[31:24] 23 22 21 20 19 18 17 16 rar[23:16] 15 14 13 12 11 10 9 8 rar[15:8] 76543210 rar[7:0]
428 32117b?avr-03/11 at32uc3c 21.7.12 write address register x name: war0, war1, war2, war3 access type: read/write offset: 0x48, 0x58, 0x68, 0x78 reset value: 0x000000000 ? war: write address register the memory address that the next write access will be done to. must be aligned according to the transfer size. 31 30 29 28 27 26 25 24 war[31:24] 23 22 21 20 19 18 17 16 war[23:16] 15 14 13 12 11 10 9 8 war[15:8] 76543210 war[7:0]
429 32117b?avr-03/11 at32uc3c 21.7.13 channel control register x name: ccr0, ccr1, ccr2, ccr3 access type: read/write offset: 0x4c, 0x5c, 0x6c, 0x7c reset value: 0x000000000 ? bswp: byte swap allows swapping of the transferred bytes, see section 21.4.2 . assuming the word output from the zero-extension module contains the bytes {a, b, c, d}. the following will be put into the fifo for transmission: 0: {a, b, c, d} 1: {d, c, b, a} 2: {c, d, a, b} 3: {b, a, d, c} ? l: last descriptor in chain used only if the channel is in descriptor mode. 0: the descriptor read in is not the last descriptor in the chai n. the next descriptor to be read is located at the address of the previously read descriptor + 4 words. 1: the descriptor read in is the last descriptor in the chain. th e next descriptor to be read is located at the address in the descriptor start address register (dsarx) for the channel. ? v: descriptor valid used only if the channel is in descriptor mode. 0: the descriptor read in is not valid. 1: the descriptor read in is valid. ? tcie: transfer complete interrupt enable 0: transfer complete does not set the isr.chxc bit. 1: transfer complete sets the isr.chxc bit. ? burst: transfer burst size indicates the size of the burst used for data transfer. the mdma will always try to use this burst size to perform transfers, b ut may be forced to use smaller sizes since the transfer count may not be perfectly divisible by the transfer data size. 0: single transfer 1: 4-beat burst 2: 8-beat burst 3: 16-beat burst 31 30 29 28 27 26 25 24 ------ bswp 23 22 21 20 19 18 17 16 - l v tcie burst size 15 14 13 12 11 10 9 8 tcnt[15:8] 76543210 tcnt[7:0]
430 32117b?avr-03/11 at32uc3c ? size: transfer data size indicates the size of data to transfer. 0: byte 1: halfword 2: word 3: unused ? tcnt: transfer count the number of data to transfer. the size of each data is given in the size field. configuring a transfer with a tcnt of 0 is illegal, and may result in undefined behavior.
431 32117b?avr-03/11 at32uc3c 21.8 module configuration the specific configuration for each mdma inst ance is listed in the following tables. the module bus clocks listed here are conn ected to the system bus clocks. refer to the power manager chapter for details. table 21-2. module configuration feature mdma channels 1 maximum burst size single transfer table 21-3. module clock name module name clock name description mdma clk_mdma_hsb hsb clock clk_mdma_pb peripheral bus clock from the pbc clock domain table 21-4. register reset values register reset value vr 0x00000101 pr 0x00000001
432 32117b?avr-03/11 at32uc3c 22. secure access unit (sau) rev: 1.1.1.3 22.1 features ? remaps registers in memory regions protected by the mpu to regions not protected by the mpu ? programmable physical address for each channel ? two modes of operation: locked and open ? in locked mode, access to a channel must be preceded by an unlock action ? an unlocked channel remains op en only for a specific amount of time, if no access is performed during this time, the channel is relocked ? only one channel can be open at a time, op ening a channel while another one is open locks the first one ? access to a locked channel is denied, a bus error and optionally an interrupt is returned ? if a channel is relocked due to an unlock timeout, an interrupt can optionally be generated ? in open mode, all channels are permanently unlocked 22.2 overview in many systems, erroneous access to peripherals can lead to catastrophic failure. an example of such a peripheral is the pulse width modula tor (pwm) used to control electric motors. the pwm outputs a pulse train that controls the moto r. if the control registers of the pwm module are inadvertently updated with wrong values, the motor can start operating out of control, possi- bly causing damage to the application and the surrounding environment. however, sometimes the pwm control registers must be updated with new values, for example when modifying the pulse train to accelerate the motor. a mechanism must be used to protect the pwm control reg- isters from inadvertent access caused by for example: ? errors in the software code ? transient errors in the cpu caused by for example electrical noise altering the execution path of the program to improve the security in a computer system, the avr32uc implements a memory protection unit (mpu). the mpu can be set up to limit the accesses that can be performed to specific memory addresses. the mpu divides the memory space into regions, and assigns a set of access restrictions on each region. access restrictions can for example be read/write if the cpu is in supervisor mode, and read-on ly if the cpu is in application mode. the regions can be of dif- ferent size, but each region is usually quite larg e, e.g. protecting 1 kilobyte of address space or more. furthermore, access to each region is often controlled by the execution state of the cpu, i.e. supervisor or application mode. such a simple control mechanism is often too inflexible (too coarse-grained chunks) and with too much overhead (often requir ing system calls to access pro- tected memory locations) for simple or real-time systems such as embedded microcontrollers. usually, the secure access unit (sau) is used together with the mpu to provide the required security and integrity. the mpu is set up to protect regions of memory, while the sau is set up to provide a secure channel into specific me mory locations that are protected by the mpu. these specific locations can be thought of as fine-grained overrides of the general coarse- grained protection provided by the mpu.
433 32117b?avr-03/11 at32uc3c 22.3 block diagram figure 22-1 presents the sau integrated in an exampl e system with a cpu, some memories, some peripherals, and a bus system. the sau is connected to both the peripheral bus (pb) and the high speed bus (hsb). configuration of the sau is done via the pb, while memory accesses are done via the hsb. the sau receives an access on its hsb slave interface, remaps it, checks that the channel is unlocked, and if so, initiates a transfer on its hsb master interface to the remapped address. the thin arrows in figure 22-1 exemplifies control flow when using the sau. the cpu wants to read the rx buffer in the usart. the mpu has been configured to protect all registers in the usart from user mode access, while the sau has been configured to remap the rx buffer into a memory space that is not protected by t he mpu. this unprotected memory space is mapped into the sau hsb slave space. when the cpu reads the appropriate address in the sau, the sau will perform an access to the desired rx buffer register in the usart, and therea fter return the read results to the cpu. th e return data flow will follow the op posite direction of the control flow arrows in figure 22-1 . figure 22-1. sau block diagram sau channel bus master mpu cpu bus slave usart pwm bus slave bus master bus slave flash bus slave ram bus bridge sau configuration interrupt request high speed bus sau peripheral bus
434 32117b?avr-03/11 at32uc3c 22.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 22.4.1 power management if the cpu enters a sleep mode that disables clocks used by the sau, the sau will stop func- tioning and resume operation after the system wakes up from sleep mode. 22.4.2 clocks the sau has two bus clocks connected: o ne high speed bus clock (clk_sau_hsb) and one peripheral bus clock (clk_sau_pb). these clocks are generated by the power manager. both clocks are enabled at reset, and can be disabled by writing to the power manager. the user has to ensure that clk_sau_hsb is not turned off before accessing the sau. likewise, the user must ensure that no bus acce ss is pending in the sau before disabling clk_sau_hsb. failing to do so may deadlock the high speed bus. 22.4.3 interrupt the sau interrupt request line is connected to th e interrupt controller. using the sau interrupt requires the interrupt controller to be programmed first. 22.4.4 debug operation when an external debugger forces the cpu into debug mode, the sau continues normal opera- tion. if the sau is configured in a way that r equires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. 22.5 functional description 22.5.1 enabling the sau the sau is enabled by wr iting a one to the enable (en) bit in the control regist er (cr). this will set the sau enabled (en) bit in the status register (sr). 22.5.2 configuring the sau channels the sau has a set of channels, mapped in the hsb memory space. these channels can be configured by a remap target register (rtr), located at the same memory address. when the sau is in normal mode, the sau channel is addressed, and when the sau is in setup mode, the rtr can be addressed. before the sau can be used, the channels must be configured and enabled. to configure a channel, the corresponding rtr must be programmed with the remap target address. to do this, make sure the sau is in setup mode by writing a one to the setup mode enable (sen) bit in cr. this makes sure that a write to the rtr address accesses the rtr, not the sau chan- nel. thereafter, the rtr is written with the address to remap to, typically the address of a specific pb register. when all channels have been configured, return to normal mode by writing a one to the setup mode disable (sdis) in cr. the channels can now be enabled by writing ones to the corresponding bits in the channel enable registers (cerh/l). the sau is only able to remap addresses above 0xfffc0000.
435 32117b?avr-03/11 at32uc3c 22.5.2.1 protecting sau configuration registers in order to prevent the sau configuration registers to be changed by malicious or runaway code, they should be protected by the mpu as soon as they have been configured. maximum security is provided in the system if pr ogram memory does not contain any code to unprotect the config- uration registers in the mpu. this guarantees t hat runaway code can not accidentally unprotect and thereafter change the sau configuration registers. 22.5.3 lock mechanism the sau can be configured to use two different access mechanisms: open and locked. in open mode, sau channels can be accessed fr eely after they have been configured and enabled. in order to prevent accidental accesses to remapped addresses, it is possible to config- ure the sau in locked mode. writing a one to the open mode bit in the config register (config.open) will enable open mode. writing a zero to config.open will enable locked mode. when using locked mode, the lock mechanism must be configured by writing a user defined key value to the unlock key (ukey) field in the configuration register (config). the number of clk_sau_hsb cycles the channel remains unlock ed must be written to the unlock number of clock cycles (ucyc) field in config. access control to the sau channels is enabled by means of the unlock register (ur), which resides in the same address space as the sa u channels. before a channel can be accessed, the unlock register must be written with th correct key and channel number (single write access). access to the channel is then permitted for the next config.ucyc clock cycles, or until a suc- cessful access to the unlocked channel has been made. only one channel can be unlocked at a time. if any other channel is unlocked at the time of writ- ing ur, this channel will be automatically locked before the cha nnel addressed by the ur write is unlocked. an attempted access to a lo cked channel will be aborted, an d the channel access unsuccessful bit (sr.cau) will be set. any pending errors bits in sr must be cleared before it is possible to access ur. the following sr bits are defined as error bits: exp, cau, urread, urkey, ures, mberror, rtradr. if any of these bits are set while writing to ur, the write is aborted and the unlock register error status (ures) bit in sr is set. 22.5.4 normal operation the following sequence must be used in order to access a sau channel in normal operation (cr.sen=0): 1. if not in open mode, write the unlock key to ur.key and the channel number to ur.channel. 2. perform the read or write operation to the sau channel. if not in open mode, this must be done within config.ucyc clock cycles of unlocking the channel. the sau will use its hsb master interface to remap the access to the target address pointed to by the corresponding rtr. 3. to confirm that the access was successful, wait for the idle transfer status bit (sr.idle) to indicate the operation is completed. then check sr for possible error con- ditions. the sau can be configured to generate interrupt requests or a bus error exception if the access failed.
436 32117b?avr-03/11 at32uc3c 22.5.4.1 operation example figure 22-2 shows a typical memory map, consisting of some memories, some simple peripher- als, and a sau with multiple channels and an unlock register (ur). imagine that the mpu has been set up to disallow all accesses from the cpu to the grey modules. thus the cpu has no way of accessing for example the transmit holding register in the uart, present on address x on the bus. note that the sau rtrs are not protected by the mpu, thus the rtrs can be accessed. if for example rtr0 is configured to point to addres s x, an access to rtr0 will be remapped by the sau to address x according to the algorithm presented above. by program- ming the sau rtrs, specific addresses in modules that have generally been protected by the mpu can be performed. figure 22-2. example memory map for a system with sau 22.5.5 interrupts the sau can generate an interrupt request to signal different events. all events that can gener- ate an interrupt requ est have dedicated bits in the status register (sr). an interrupt request will be generated if the corresponding bit in the interrupt mask register (imr) is set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier), and cleared by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt request remains active until the corresponding bit in sr is cleared by writing a one to the corre- sponding bit in the interrupt clear register (icr). the following sr bits are used for si gnalling the result of sau accesses: ? rtr address error (rtradr) is set if an ille gal address is written to the rtrs. only addresses in the range 0xfffc0000-0xffffffff are allowed. ? master interface bus error (mberror) is set if any of the conditions listed in section 22.5.7 occurred. transmit holding baudrate control receive holding channel 1 rtr0 rtr1 address x address z uart sau config sau channel ur rtr62 ...
437 32117b?avr-03/11 at32uc3c ? unlock register error status (ures) is set if an attempt was made to unlock a channel by writing to the unlock regist er while one or more error bits in sr were set (see section 22.5.6 ). the unlock operation was aborted. ? unlock register key error (urkey) is set if the unlock register was attempted written with an invalid key. ? unlock register read (urread) is set if the unlock register was attempted read. ? channel access unsuccessful (cau) is set if the channel access was unsuccessful. ? channel access successful (cas) is set if the channel access was successful. ? channel unlock expired (exp) is set if the channel lock expired, with no channel being accessed after the channel was unlocked. 22.5.6 error bits if error bits are set when atte mpting to unlock a channel, sr.ures will be set. the following sr bits are considered error bits: ? exp ?cau ? urread ? urkey ?ures ? mberror ?rtradr 22.5.7 bus error responses by writing a one to the bus er ror response enable bit (cr.be rren), serious access errors will be configured to return a bus error to the cpu. this will ca use the cpu to execute its bus error data fetch exception routine. the conditions that can generate a bus error response are: ? reading the unlock register ? trying to access a locked channel ? the sau hsb master receiving a bus error response from its addressed slave 22.5.8 disabling the sau to disable the sau, the user must first ensure that no sau bus operations are pending. this can be done by checking that the sr.idle bit is set. the sau may then be disabled by writing a one to the disable (dis) bit in cr.
438 32117b?avr-03/11 at32uc3c 22.6 user interface the following addresses are used by sau channel configuration r egisters. all offsets are relative to the sau?s pb base address. note: 1. the reset values are device specific. please refer to the module configuration section at the end of this chapter. the following addresses are used by sau channel registers. a ll offsets are relative to the sau?s hsb base address. the number of channels implemented is device specific, refer to the module configuration section at the end of this chapter. table 22-1. sau configuration re gister memory map offset register register name access reset 0x00 control register cr write-only 0x00000000 0x04 configuration register config write-only 0x00000000 0x08 channel enable register high cerh read/write 0x00000000 0x0c channel enable register low cerl read/write 0x00000000 0x10 status register sr read-only 0x00000400 0x14 interrupt enable register ier write-only 0x00000000 0x18 interrupt disable register idr write-only 0x00000000 0x1c interrupt mask register imr read-only 0x00000000 0x20 interrupt clear register icr write-only 0x00000000 0x24 parameter register parameter read-only - (1) 0x28 version register version read-only - (1) table 22-2. sau channel register memory map offset register register name access reset 0x00 remap target register 0 rtr0 read/write n/a 0x04 remap target register 1 rtr1 read/write n/a 0x08 remap target register 2 rtr2 read/write n/a ... ... ... ... ... 0x04*n remap target register n rtrn read/write n/a 0xfc unlock register ur write-only n/a
439 32117b?avr-03/11 at32uc3c 22.6.1 control register name: cr access type: write-only offset: 0x00 reset value: 0x00000000 ? berrdis: bus error response disable writing a zero to this bit has no effect. writing a one to this bit disables bus error response from the sau. ? berren: bus error response enable writing a zero to this bit has no effect. writing a one to this bit enables bus error response from the sau. ? sdis: setup mode disable writing a zero to this bit has no effect. writing a one to this bit exits setup mode. ? sen: setup mode enable writing a zero to this bit has no effect. writing a one to this bit enters setup mode. ? dis: sau disable writing a zero to this bit has no effect. writing a one to this bit disables the sau. ? en: sau enable writing a zero to this bit has no effect. writing a one to this bit enables the sau. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - berrdis berren sdis sen dis en
440 32117b?avr-03/11 at32uc3c 22.6.2 configuration register name: config access type: write-only offset: 0x04 reset value: 0x00000000 ? open: open mode enable writing a zero to this bit disables open mode. writing a one to this bit enables open mode. ? ucyc: unlock number of clock cycles once a channel has been unlocked, it remains unlocked for this amount of clk_sau_hsb clock cycles or until one access to a channel has been made. ? ukey: unlock key the value in this register must be written into ur.key to unlock a channel. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------open 15 14 13 12 11 10 9 8 ucyc 76543210 ukey
441 32117b?avr-03/11 at32uc3c 22.6.3 channel enable register high name: cerh access type: read/write offset: 0x08 reset value: 0x00000000 ? cerh[n]: channel enable register high 0: channel (n+32) is not enabled. 1: channel (n+32) is enabled. 31 30 29 28 27 26 25 24 - cerh[30:24] 23 22 21 20 19 18 17 16 cerh[23:16] 15 14 13 12 11 10 9 8 cerh[15:8] 76543210 cerh[7:0]
442 32117b?avr-03/11 at32uc3c 22.6.4 channel enable register low name: cerl access type: read/write offset: 0x0c reset value: 0x00000000 ? cerl[n]: channel enable register low 0: channel n is not enabled. 1: channel n is enabled. 31 30 29 28 27 26 25 24 cerl[31:24] 23 22 21 20 19 18 17 16 cerl[23:16] 15 14 13 12 11 10 9 8 cerl[15:8] 76543210 cerl[7:0]
443 32117b?avr-03/11 at32uc3c 22.6.5 status register name: sr access type: read-only offset: 0x10 reset value: 0x00000400 ?idle this bit is cleared when a read or write operation to the sau channel is started. this bit is set when the operation is completed and no sau bus operations are pending. ? sen: sau setup mode enable this bit is cleared when the sau exits setup mode. this bit is set when th e sau enters setup mode. ? en: sau enabled this bit is cleared when the sau is disabled. this bit is set when the sau is enabled. ? rtradr: rtr address error this bit is cleared when the corresponding bit in icr is written to one. this bit is set if, in the configuration phase, an rtr was wr itten with an illegal address, i.e. the upper 16 bits in the addre ss were different from 0xfffc, 0xfffd, 0xfffe or 0xffff. ? mberror: master interface bus error this bit is cleared when the corresponding bit in icr is written to one. this bit is set if a channel access generated a transfer on the master interface that received a bus error response from the addressed slave. ? ures: unlock register error status this bit is cleared when the corresponding bit in icr is written to one. this bit is set if an attempt was made to unlock a channel by writing to the unlock register while one or more error bits were set in sr. the unlock operation was aborted. ? urkey: unlock register key error this bit is cleared when the corresponding bit in icr is written to one. this bit is set if the unlock register was attempted written with an invalid key. ? urread: unlock register read this bit is cleared when the corresponding bit in icr is written to one. this bit is set if the unlock register was read. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -----idlesenen 76543210 rtradr mberror ures urkey urread cau cas exp
444 32117b?avr-03/11 at32uc3c ? cau: channel access unsuccessful this bit is cleared when the corresponding bit in icr is written to one. this bit is set if channel access was unsuccessful, i.e. an access was attempted to a locked or disabled channel. ? cas: channel access successful this bit is cleared when the corresponding bit in icr is written to one. this bit is set if channel access successful, i.e. one access was made after the channel was unlocked. ? exp: channel unlock expired this bit is cleared when the corresponding bit in icr is written to one. this bit is set if channel unlock has expired, i.e. no access being made after the channel was unlocked.
445 32117b?avr-03/11 at32uc3c 22.6.6 interrupt enable register name: ier access type: write-only offset: 0x14 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 rtradr mberror ures urkey urread cau cas exp
446 32117b?avr-03/11 at32uc3c 22.6.7 interrupt disable register name: idr access type: write-only offset: 0x18 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 rtradr mberror ures urkey urread cau cas exp
447 32117b?avr-03/11 at32uc3c 22.6.8 interrupt mask register name: imr access type: read-only offset: 0x1c reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 rtradr mberror ures urkey urread cau cas exp
448 32117b?avr-03/11 at32uc3c 22.6.9 interrupt clear register name: icr access type: write-only offset: 0x20 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in sr and any corresponding interrupt request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 rtradr mberror ures urkey urread cau cas exp
449 32117b?avr-03/11 at32uc3c 22.6.10 parameter register name: parameter access type: read-only offset: 0x24 reset value: - ? channels: number of channels implemented 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - channels
450 32117b?avr-03/11 at32uc3c 22.6.11 version register name: version access type: write-only offset: 0x28 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
451 32117b?avr-03/11 at32uc3c 22.6.12 remap target register n name: rtrn access type: read/write offset: n*4 reset value: 0x00000000 ? rtr: remap target address for channel n rtr[31:16] must have one of the following values, any other value will result in undefined behavior: 0xfffc 0xfffd 0xfffe 0xffff rtr[1:0] must be written to 0, any othe r value will result in undefined behavior. 31 30 29 28 27 26 25 24 rtr[31:24] 23 22 21 20 19 18 17 16 rtr[23:16] 15 14 13 12 11 10 9 8 rtr[15:8] 76543210 rtr[7:0]
452 32117b?avr-03/11 at32uc3c 22.6.13 unlock register name: ur access type : write-only offset: 0xfc reset value: 0x00000000 ?key: unlock key the correct key must be written in order to unlock a channel. the key value written must correspond to the key value defined in config.ukey. ? channel: channel number number of the channel to unlock. 31 30 29 28 27 26 25 24 - 23 22 21 20 19 18 17 16 - 15 14 13 12 11 10 9 8 key 76543210 - - channel
453 32117b?avr-03/11 at32uc3c 22.7 module configuration the specific configuration for each sau instance is listed in the following tables. the module bus clocks listed here are conn ected to the system bus clocks. refer to the power manager chapter for details. table 22-3. module configuration feature sau sau channels 16 table 22-4. module clock name module name clock name description sau clk_sau_hsb hsb clock clk_sau_pb peripheral bus clock from the pbb clock domain table 22-5. register reset values register reset value version 0x111 pa r a m e t e r 0 x 0 1 0
454 32117b?avr-03/11 at32uc3c 23. general-purpose input/ output controller (gpio) rev: 2.1.2.5 23.1 features ? each gpio line features: ? configurable pin-change, rising-edge, or falling-edge interrupt ? glitch filter providing rejection of pulses shorter than one clock cycle ? input visibility and output control ? multiplexing of peripheral functions on i/o pins ? programmable internal pull-up resistor ? programmable internal pull-down resistor ? programmable output driver strength ? optional locking of configuration to avoid accidental reconfiguration 23.2 overview the general purpose input/output controller (gpio) controls the i/o pins of the microcontroller. each gpio pin may be used as a general-purpose i/o or be assigned to a function of an embed- ded peripheral. the gpio is configured using the peripheral bus (pb). some registers can also be configured using the low latency cpu local bus. see section 23.6.2.8 for details. 23.3 block diagram figure 23-1. gpio block diagram interrupt controller power manager embedded peripheral general purpose input/output - gpio gpio interrupt request clk_gpio pin control signals pin pin pin pin pin mcu i/o pins configuration interface
455 32117b?avr-03/11 at32uc3c 23.4 i/o lines description 23.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 23.5.1 power management if the cpu enters a sleep mode that disables cl ocks used by the gpio, the gpio will stop func- tioning and resume operation after the system wakes up from sleep mode. if a peripheral function is configured for a gpio pin, the peripheral will be able to control the gpio pin even if the gpio clock is stopped. 23.5.2 clocks the gpio is connected to a peripheral bus clock (clk_gpio). this clock is generated by the power manager. clk_gpio is enabled at reset, and can be disabled by writing to the power manager. clk_gpio must be enabled in order to access the configuration registers of the gpio or to use the gpio interrupts. after configuring the gpio, the clk_gpio can be disabled by writing to the power manager if interrupts are not used. if the cpu local bus is used to access the c onfiguration interface of the gpio, the clk_gpio must be equal to the cpu clock to avoid data loss. 23.5.3 interrupts the gpio interrupt request lines are connected to the interrupt controller. using the gpio inter- rupts requires the interrupt controller to be programmed first. 23.5.4 debug operation when an external debugger forces the cpu into debug mode, the gpio continues normal oper- ation. if the gpio is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. pin name description type gpion gpio pin n digital
456 32117b?avr-03/11 at32uc3c 23.6 functional description the gpio controls the i/o pins of the microcontr oller. the control logic associated with each pin is shown in the figure below. figure 23-2. overview of the gpio 0 1 gpio_odmer 0 1 0 1 gper 1 0 ovr oder pmrn periph. func. a periph.func. b periph. func. c pin puer* pvr 0 1 glitch filter gfer edge detector 1 0 interrupt request imr1 imr0 ier odcrn* osrrn* drive strength and slew rate control ster* schmitt trigger pder* pullup, pulldown and buskeeper .... output output enable input *) register value is overrided if a peripheral function that support this function is enabled ifr
457 32117b?avr-03/11 at32uc3c 23.6.1 basic operation 23.6.1.1 module configuration the gpio user interface registers are organiz ed into ports and each port controls 32 different gpio pins. most of the registers supports bit wise access operations such as set, clear and tog- gle in addition to the standard word access. for details regarding interface registers, refer to section 23.7 . 23.6.1.2 available features most of the gpio features are configurable for each product. the programmer must refer to the module configuration section and the gpio f unction multiplexing section in the package and pinout chapter for the configuration used in this product. product specific settings includes: ? number of gpio pins ? functions implemented on each pin ? peripheral function(s) multiplexed on each gpio pin ? reset state of registers 23.6.1.3 inputs the level on each gpio pin can be read through the pin value register (pvr). this register indicates the level of the gpio pins regardless of the pins being driven by the gpio or by an external component. note that due to power saving measures , the pvr register will only be updated when the corresponding bit in gper is one or if an interrupt is enabled for the pin, i.e. ier is one for the corresponding pin. 23.6.1.4 output control when the gpio pin is assigned to a peripheral function, i.e. the corresponding bit in gper is zero, the peripheral determines whether the pin is driven or not. when the gpio pin is controlled by the gpio, the value of output driver enable register (oder) determines whether the pin is driven or not. when a bit in this register is one, the corre- sponding gpio pin is driven by the gpio. when the bit is zero, the gpio does not drive the pin. the level driven on a gpio pin can be determined by writing the value to the corresponding bit in the output value register (ovr). 23.6.1.5 peripheral muxing the gpio allows a single gpio pin to be shared by multiple peripheral pins and the gpio itself. peripheral pins sharing the same gpio pin are arranged into peripheral functions that can be selected one at a time. peripheral functions are configured by writing the selected function value to the peripheral mux registers (pmrn). to allow a peripheral pin access to the shared gpio pin, gpio control must be disabled for that pin, i.e. the corresponding bit in gper must read zero. a peripheral function value is set by writing bit zero to pmr0 and bit one to the same index posi- tion in pmr1 and so on. in a system with 4 peripheral functions a,b,c, and d, peripheral function c for gpio pin four is selected by writi ng a zero to bit four in pmr0 and a one to the same bit index in pmr1. refer to the gpio function multiplexing chapter for details regarding pin function configuration for each gpio pin.
458 32117b?avr-03/11 at32uc3c 23.6.2 advanced operation 23.6.2.1 peripheral i/o pin control when a gpio pin is assigned to a peripheral function, i.e. the corresponding bit in gper is zero, output and output enable is controlled by the selected peripheral pin. in addition the peripheral may control some or all of the other gpio pin functions listed in table 23-1 , if the peripheral sup- ports those features. all pin features not controlled by the selected peripheral is controlled by the gpio. refer to the module configuration section for details regarding implemented gpio pin functions and to the peripheral chapter for details regarding i/o pin function control. 23.6.2.2 pull-up resistor, pull-down resistor control pull-up and pull-down can be configured for each gpio pin. pull-up allows the pin and any con- nected net to be pulled up to vdd if the net is not driven. pull-down pulls the net to gnd. pull-up and pull-down are useful for detecting if a pin is unconnected or if a mechanical button is pressed, for various communication protocols an d to keep unconnected pins from floating. pull-up can be enabled and disabled by writing a one and a zero respectively to the correspond- ing bit in the pull-up enable register (puer). pu ll-down can be enabled and disabled by writing a one and a zero respectively to the correspondi ng bit in the pull-down en able register (pder). 23.6.2.3 output pin timings figure 23-3 shows the timing of the gpio pin when writing to the output value register (ovr). the same timing applies when performing a ?set? or ?clear? access, i.e. writing to ovrs or ovrc. the timing of pvr is also shown. figure 23-3. output pin timings table 23-1. i/o pin function control function name gpio mode peripheral mode output ovr peripheral output enable oder peripheral pull-up puer peripheral if supported, else gpio pull-down pder peripheral if supported, else gpio drive strength odcrn peripheral if supported, else gpio pb access pb access clk_gpio write ovr to 1 write ovr to 0 ovr / i/o line pvr
459 32117b?avr-03/11 at32uc3c 23.6.2.4 pin output driver control the gpio has registers for contro lling output drive propert ies of each pin, such as output driving capability. the driving capability is cont rolled by the output driving capability registers (odcrn). 23.6.2.5 interrupts the gpio can be configured to generate an inte rrupt when it detects a change on a gpio pin. interrupts on a pin are enabled by writing a one to the corresponding bit in the interrupt enable register (ier). the module can be configured to generate an interrupt whenever a pin changes value, or only on rising or falling edges. this is controlled by the interrupt mode registers (imrn). interrupts on a pin can be enabled rega rdless of the gpio pin being controlled by the gpio or assigned to a peripheral function. an interrupt can be generated on each gpio pin. these interrupt generators are further grouped into groups of eight and connected to the interrupt controller. an interrupt request from any of the gpio pin generators in the group will result in an interrupt request from that group to the inter- rupt controller if the corresponding bit for the gp io pin in the ier is set. by grouping interrupt generators into groups of eight, four different interrupt handlers can be installed for each gpio port. the interrupt flag register (ifr) can be read by software to determine which pin(s) caused the interrupt. the interrupt flag must be manually cleared by writing a zero to the corresponding bit in ifr. gpio interrupts will only be gener ated when clk_gpio is enabled. 23.6.2.6 input glitch filter input glitch filters can be enabled on each gpio pi n. when the glitch filter is enabled, a glitch with duration of less than 1 clk_gpio cycle is automatically rejected, while a pulse with dura- tion of 2 clk_gpio cycles or more is accepted. for pulse durations between 1 and 2 clk_gpio cycles, the pulse may or may not be taken into account, depending on the precise timing of its occurrence. thus for a pulse to be guaranteed visible it must exceed 2 clk_gpio cycles, whereas for a glitch to be reliably filtered out, its duration must not exceed 1 clk_gpio cycle. the filter introduces 2 clock cycles latency. the glitch filters are controlled by the glitch filter enable register (gfer). when a bit in gfer is one, the glitch filter on the corresponding pin is enabled. the glitch filter affects only interrupt inputs. inputs to peripherals or the value read through pvr are not affected by the glitch filters. 23.6.2.7 interrupt timings figure 23-4 shows the timing for rising edge (or pin-change) interrupts when the glitch filter is disabled. for the pulse to be registered, it must be sampled at the rising edge of the clock. in this example, this is not the case for the first pulse. the second pulse is sampled on a rising edge and will trigger an interrupt request.
460 32117b?avr-03/11 at32uc3c figure 23-4. interrupt timing with glitch filter disabled figure 23-5 shows the timing for rising edge (or pin-change) interrupts when the glitch filter is enabled. for the pulse to be registered, it must be sampled on two subsequent rising edges. in the example, the first pulse is rejected while th e second pulse is accepted and causes an inter- rupt request. figure 23-5. interrupt timing with g litch filter enabled 23.6.2.8 cpu local bus the cpu local bus can be used for application where low latency read and write access to the output value register (ovr) and output drive enable register (oder) is required. the cpu local bus allows the cpu to configure the mentioned gpio registers directly, bypassing the shared peripheral bus (pb). to avoid data loss when using the cpu local bus, the clk_gpio must run at the same fre- quency as the clk_cpu. see section 23.5.2 for details. the cpu local bus is mapped to a different base address than the gpio but the over and oder offsets are the same. see the cpu local bus mapping section in the memories chapter for details. clk_gpio pin level ifr clk_gpio pin level ifr
461 32117b?avr-03/11 at32uc3c 23.7 user interface the gpio controller manages all the gpio pins on the 32-bit avr microcontroller. the pins are managed as 32-bit ports that are configurable through a peripheral bus (pb) interface. each port has a set of configuration registers. the ov erall memory map of the gpio is shown below. the number of pins and hence the number of ports is product specific. figure 23-6. port configuration registers in the peripheral muxing table in the package and pinout chapter each gpio pin has a unique number. note that the pa, pb, pc, and px ports do not necessarily directly correspond to the gpio ports. to find the corresponding port and pin the following formulas can be used: gpio port = floor((gpio number) / 32), example: floor((36)/32) = 1 gpio pin = gpio number % 32, example: 36 % 32 = 4 table 23-2 shows the configuration registers for one port. addresses shown are relative to the port address offset. the specific address of a co nfiguration register is found by adding the regis- ter offset and the port offset to the gpio start address. one bit in each of the configuration registers corresponds to a gpio pin. 23.7.1 access types most configuration register can be accessed in four different ways. the first address location can be used to write the register directly. this address can also be used to read the register value. the following addresses facilitate th ree different types of write acce ss to the regi ster. performing a ?set? access, all bits written to one will be se t. bits written to zero will be unchanged by the operation. performing a ?clear? a ccess, all bits written to one will be cleared. bits written to zero will be unchanged by the operation. finally, a toggle access will toggle the value of all bits writ- port 0 configuration registers port 1 configuration registers port 2 configuration registers port n configuration registers 0x0000 0x0200 0x0400 n*0x200 ?.
462 32117b?avr-03/11 at32uc3c ten to one. again all bits written to zero remain unchanged. note that for some registers (e.g. ifr), not all access methods are permitted. note that for ports with less than 32 bits, the corresponding control registers will have unused bits. this is also the case for features that are not implemented for a specific pin. writing to an unused bit will have no effect. reading unused bits will always return 0. 23.7.2 configuration protection in order to protect the configuration of individual gpio pins from software failure, configuration bits for individual gpio pins may be locked by writing a one to the corresponding bit in the lock register. while this bit is one, any write to the same bit position in any lockable gpio register using the peripheral bus (pb) will not have an effect. the cpu local bus is not checked and thus allowed to write to all bits in a cpu local bus mapped register no mather the lock value. the registers required to clear bits in the lock register are protected by the access protection mechanism described in section 23.7.3 , ensuring the lock mechanis m itself is robust against software failure. 23.7.3 access protection in order to protect critical registers from software failure, some registers are protected by a key protection mechanism. these registers can only be changed by first writing the unlock regis- ter, then the protected register. protected registers are indicated in table 23-2 . the unlock register contains a key field which must always be written to 0xaa, and an offset field corre- sponding to the offset of the register to be modified. the next write operation resets the unlock register, so if the register is to be modified again, the unlock register must be written again. attempting to write to a protected register without first writing the unlock register results in the write operation being discarded, and the access error bit in the access status register (asr.ae) will be set. table 23-2. gpio register memory map offset register function register name access reset config. protection access protection 0x000 gpio enable register read/write gper read/write - (1) yn 0x004 gpio enable register set gpers write-only y n 0x008 gpio enable register clear gperc write-only y n 0x00c gpio enable register toggle gpert write-only y n 0x010 peripheral mux register 0 read/write pmr0 read/write - (1) y n 0x014 peripheral mux register 0 set pmr0s write-only y n 0x018 peripheral mux register 0 clear pmr0c write-only y n 0x01c peripheral mux register 0 toggle pmr0t write-only y n 0x020 peripheral mux register 1 read/write pmr1 read/write - (1) yn 0x024 peripheral mux register 1 set pmr1s write-only y n 0x028 peripheral mux register 1 clear pmr1c write-only y n
463 32117b?avr-03/11 at32uc3c 0x02c peripheral mux register 1 toggle pmr1t write-only y n 0x030 peripheral mux register 2 read/write pmr2 read/write - (1) y n 0x034 peripheral mux register 2 set pmr2s write-only y n 0x038 peripheral mux register 2 clear pmr2c write-only y n 0x03c peripheral mux register 2 toggle pmr2t write-only y n 0x040 output driver enable register read/write oder read/write - (1) yn 0x044 output driver enable register set oders write-only y n 0x048 output driver enable register clear oderc write-only y n 0x04c output driver enable register toggle odert write-only y n 0x050 output value register read/write ovr read/write - (1) n n 0x054 output value register set ovrs write-only n n 0x058 output value register clear ovrc write-only n n 0x05c output value register toggle ovrt write-only n n 0x060 pin value register read pvr read-only depe nding on pin states nn 0x064 pin value register - - - n n 0x068 pin value register - - - n n 0x06c pin value register - - - n n 0x070 pull-up enable register read/write puer read/write - (1) y n 0x074 pull-up enable register set puers write-only y n 0x078 pull-up enable register clear puerc write-only y n 0x07c pull-up enable register toggle puert write-only y n 0x080 pull-down enable register read/write pder read/write (1) y n 0x084 pull-down enable register set pders write-only y n 0x088 pull-down enable register clear pderc write-only y n 0x08c pull-down enable register toggle pdert write-only y n 0x090 interrupt enable register read/write ier read/write - (1) n n 0x094 interrupt enable register set iers write-only n n 0x098 interrupt enable register clear ierc write-only n n 0x09c interrupt enable register toggle iert write-only n n 0x0a0 interrupt mode register 0 read/write imr0 read/write - (1) nn 0x0a4 interrupt mode register 0 set imr0s write-only n n 0x0a8 interrupt mode register 0 clear imr0c write-only n n 0x0ac interrupt mode register 0 toggle imr0t write-only n n table 23-2. gpio register memory map offset register function register name access reset config. protection access protection
464 32117b?avr-03/11 at32uc3c note: 1. the reset values for these registers are device specific. please refer to the module configuration section at the end of this chapter. 0x0b0 interrupt mode register 1 read/write imr1 read/write - (1) n n 0x0b4 interrupt mode register 1 set imr1s write-only n n 0x0b8 interrupt mode register 1 clear imr1c write-only n n 0x0bc interrupt mode register 1 toggle imr1t write-only n n 0x0c0 glitch filter enable register read/write gfer read/write - (1) nn 0x0c4 glitch filter enable register set gfers write-only n n 0x0c8 glitch filter enable register clear gferc write-only n n 0x0cc glitch filter enable register toggle gfert write-only n n 0x0d0 interrupt flag register read ifr read-only - (1) n n 0x0d4 interrupt flag register - - - n n 0x0d8 interrupt flag register clear ifrc write-only n n 0x0dc interrupt flag register - - - n n 0x100 output driving capability regi ster 0 read/write odcr0 read/write - (1) yn 0x104 output driving capability register 0 set odcr0s write-only y n 0x108 output driving capability register 0 clear odcr0c write-only y n 0x10c output driving capability register 0 toggle odcr0t write-only y n 0x110 output driving capability register 1 read odcr1 read/write - (1) y n 0x114 output driving capability register 1 set odcr1s write-only y n 0x118 output driving capability register 1 clear odcr1c write-only y n 0x11c output driving capability register 1 toggle odcr1t write-only y n 0x1a0 lock register read/write lock read/write - (1) n y 0x1a4 lock register set locks write-only n n 0x1a8 lock register clear lockc write-only n y 0x1ac lock register toggle lockt write-only n y 0x1e0 unlock register read/write unlock write-only n n 0x1e4 access status register read/write asr read/write n 0x1f8 parameter register read pa r a m e t e r read-only - (1) n n 0x1fc version register read version read-only - (1) n n table 23-2. gpio register memory map offset register function register name access reset config. protection access protection
465 32117b?avr-03/11 at32uc3c 23.7.4 gpio enable register name: gper access: read/write, set, clear, toggle offset : 0x000, 0x004, 0x008, 0x00c reset value: - ? p0-p31: gpio enable 0: a peripheral function controls the corresponding pin. 1: the gpio controls the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
466 32117b?avr-03/11 at32uc3c 23.7.5 peripheral mux register 0 name: pmr0 access: read/write, set, clear, toggle offset : 0x010, 0x014, 0x018, 0x01c reset value: - ? p0-31: peripheral mult iplexer select bit 0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
467 32117b?avr-03/11 at32uc3c 23.7.6 peripheral mux register 1 name: pmr1 access: read/write, set, clear, toggle offset : 0x020, 0x024, 0x028, 0x02c reset value: - ? p0-31: peripheral mult iplexer select bit 1 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
468 32117b?avr-03/11 at32uc3c 23.7.7 peripheral mux register 2 name: pmr2 access: read/write, set, clear, toggle offset : 0x030, 0x034, 0x038, 0x03c reset value: - ? p0-31: peripheral mult iplexer select bit 2 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 {pmr2, pmr1, pmr0} selected peripheral function 000 a 001 b 010 c 011 d 100 e 101 f 110 g 111 h
469 32117b?avr-03/11 at32uc3c 23.7.8 output driver enable register name: oder access: read/write, set, clear, toggle offset : 0x040, 0x044, 0x048, 0x04c reset value: - ? p0-31: output driver enable 0: the output driver is disabled for the corresponding pin. 1: the output driver is enabled for the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
470 32117b?avr-03/11 at32uc3c 23.7.9 output value register name: ovr access: read/write, set, clear, toggle offset : 0x050, 0x054, 0x058, 0x05c reset value: - ? p0-31: output value 0: the value to be driven on the gpio pin is 0. 1: the value to be driven on the gpio pin is 1. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
471 32117b?avr-03/11 at32uc3c 23.7.10 pin value register name: pvr access: read-only offset : 0x060, 0x064, 0x068, 0x06c reset value: depending on pin states ? p0-31: pin value 0: the gpio pin is at level zero. 1: the gpio pin is at level one. note that the level of a pin can only be read when the corresponding pin in gper is one or interrupt is enabled for the pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
472 32117b?avr-03/11 at32uc3c 23.7.11 pull-up enable register name: puer access: read/write, set, clear, toggle offset : 0x070, 0x074, 0x078, 0x07c reset value: - ? p0-31: pull-up enable writing a zero to a bit in this register will disable pull-up on the corresponding pin. writing a one to a bit in this register will enable pull-up on the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
473 32117b?avr-03/11 at32uc3c 23.7.12 pull-down enable register name: pder access: read/write, set, clear, toggle offset : 0x080, 0x084, 0x088, 0x08c reset value: - ? p0-31: pull-down enable 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 {puer, pder} selected function 00 disabled 01 pull-down enabled 10 pull-up enabled 11 buskeeper enabled
474 32117b?avr-03/11 at32uc3c 23.7.13 interrupt enable register name: ier access: read/write, set, clear, toggle offset : 0x090, 0x094, 0x098, 0x09c reset value: - ? p0-31: interrupt enable 0: interrupt is disabled for the corresponding pin. 1; interrupt is enabled for the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
475 32117b?avr-03/11 at32uc3c 23.7.14 interrupt mode register 0 name: imr0 access: read/write, set, clear, toggle offset : 0x0a0, 0x0a4, 0x0a8, 0x0ac reset value: - ? p0-31: interrupt mode bit 0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
476 32117b?avr-03/11 at32uc3c 23.7.15 interrupt mode register 1 name: imr1 access: read/write, set, clear, toggle offset : 0x0b0, 0x0b4, 0x0b8, 0x0bc reset value: - ? p0-31: interrupt mode bit 1 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 {imr1, imr0} interrupt mode 00 pin change 01 rising edge 10 falling edge 11 reserved
477 32117b?avr-03/11 at32uc3c 23.7.16 glitch filter enable register name: gfer access: read/write, set, clear, toggle offset : 0x0c0, 0x0c4, 0x0c8, 0x0cc reset value: - ? p0-31: glitch filter enable 0: glitch filter is disabled for the corresponding pin. 1: glitch filter is enabled for the corresponding pin. note! the value of this register should only be changed when the corresponding bit in ier is zero. updating gfer while interrupt on the corresponding pin is enabled can cause an unintentional interrupt to be triggered. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
478 32117b?avr-03/11 at32uc3c 23.7.17 interrupt flag register name: ifr access: read, clear offset :0x0d0, 0x0d8 reset value: - ? p0-31: interrupt flag 0: no interrupt condition has been detected on the corresponding pin. 1: an interrupt condition has been detected on the corresponding pin. the number of interrupt request lines depe nds on the number of gpio pins on the mcu. refer to the product specific data for details. note also that a bit in the interrupt flag register is only valid if the corresponding bit in ier is one. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
479 32117b?avr-03/11 at32uc3c 23.7.18 output driving capability register 0 name: odcr0 access: read/write, set, clear, toggle offset : 0x100, 0x104, 0x108, 0x10c reset value: - ? p0-31: output driving capability register bit 0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
480 32117b?avr-03/11 at32uc3c 23.7.19 output driving capability register 1 name: odcr1 access: read/write, set, clear, toggle offset : 0x110, 0x114, 0x118, 0x11c reset value: - ? p0-31: output driving capability bit 1 for the actual drive strength of the pin, please refer to the electrical characteristics chapter. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 {odcr1, odcr0} interrupt mode 00 lowest drive strength 01 ... 10 ... 11 highest drive strength
481 32117b?avr-03/11 at32uc3c 23.7.20 lock register name: lock access: read/write, set, clear, toggle offset : 0x1a0, 0x1a4, 0x1a8, 0x1ac reset value: - ? p0-31: lock state 0: pin is unlocked. the corresponding bit can be changed in any gpio register for this port. 1: pin is locked. the corresponding bit can not be changed in any gpio register for this port. the value of lock determines which bits are locked in the lockable registers. the lock, lockc, and lockt registers are protected, which means they can only be written immediately after a write to the unlock register with the proper key and offset. locks is not protected, and can be written at any time. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
482 32117b?avr-03/11 at32uc3c 23.7.21 unlock register name: unlock access: write-only offset :0x1e0 reset value: - ? offset: register offset this field must be written with the offset va lue of the lock, lockc or lockt register to unlock. this offset must also include the port offset for the register to unlock. locks can not be locke d so no unlock is required before writing to this register. ?key: unlocking key this bitfield must be written to 0xaa for a wr ite to this register to have an effect. this register always reads as zero. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------ offset 76543210 offset
483 32117b?avr-03/11 at32uc3c 23.7.22 access status register name: asr access: read/write offset :0x1e4 reset value: - ? ae: access error this bit is set when a write to a locked register occurs. this bit can be written to 0 by software. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------ae
484 32117b?avr-03/11 at32uc3c 23.7.23 parameter register name: parameter access type: read-only offset :0x1f8 reset value: - ? parameter: 0: the corresponding pin is not implemented in this gpio port. 1: the corresponding pin is implemented in this gpio port. there is one parameter register per gpio port. each bit in the parameter register indica tes whether the corresponding gper bit is implemented. 31 30 29 28 27 26 25 24 pa r a m e t e r 23 22 21 20 19 18 17 16 pa r a m e t e r 15 14 13 12 11 10 9 8 pa r a m e t e r 76543210 pa r a m e t e r
485 32117b?avr-03/11 at32uc3c 23.7.24 version register name: version access type: read-only offset :0x1fc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 ---- version[11:8] 76543210 version[7:0]
486 32117b?avr-03/11 at32uc3c 23.8 module configuration the specific configuration for each gpio instance is listed in the following tables. the module bus clocks listed here are conn ected to the system bus clocks. refer to the power manager chapter for details. the reset values for all gpio registers are zero, with the following exceptions: table 23-3. module configuration feature gpio number of gpio ports 4 number of peripheral functions 4 table 23-4. implemented pin functions pin function implemented notes pull-up yes controlled by puer or peripheral pull-down yes controlled by pder drive strength yes writing to odcr0 c ontrol the drive strength of the pads writing to odcr1 has no effect slew rate no osrrn registers are not implemented open drain no odmern registers are not implemented bus keeper no setting {puer, pder} to 0x3 in a pin does not enable the bus keeper on this pin table 23-5. module clock name module name clock name description gpio clk_gpio peripheral bus clock from the pba clock domain table 23-6. register reset values port register reset value 0 gper 0x3ff9ffff 0 pmr0 0x00000001 0 pmr1 - pmr2 0x00000000 0 oder - ovr 0x00000000 0 puer 0x00000001 0 pder 0x00000000 0 ier - imr0 - imr1 - ifr 0x00000000 0 gfer 0x3ff9ffff 0 odcr0 0x00000000 0 lock 0x00000000 0 parameter 0x3ff9ffff
487 32117b?avr-03/11 at32uc3c 0 version 0x00000212 1 gper 0xffffffff 1 pmr0 0x00000002 1 pmr1 - pmr2 0x00000000 1 oder - ovr 0x00000000 1 puer - pder 0x00000000 1 ier - imr0 - imr1 - ifr 0x00000000 1 gfer 0xffffffff 1 odcr0 0x00000000 1 lock 0x00000000 1 parameter 0x3fffffff 1 version 0x00000212 2 gper 0xffffffff 2 pmr0 - pmr1 - pmr2 0x00000000 2 oder - ovr 0x00000000 2 puer - pder 0x00000000 2 ier - imr0 - imr1 - ifr 0x00000000 2 gfer 0xffffffff 2 odcr0 0x00000000 2 lock 0x00000000 2 parameter 0xffffffff 2 version 0x00000212 3 gper 0x7fffffff 3 pmr0 - pmr1 - pmr2 0x00000000 3 oder - ovr 0x00000000 3 puer - pder 0x00000000 3 ier - imr0 - imr1 - ifr 0x00000000 3 gfer 0x7fffffff 3 odcr0 0x00000000 3 lock 0x00000000 3 parameter 0x7fffffff 3 version 0x00000212 table 23-6. register reset values port register reset value
488 32117b?avr-03/11 at32uc3c 24. ethernet mac (macb) rev: 1.1.2.0 24.1 features ? compatible with ieee standard 802.3 ? 10 and 100 mbit/s operation ? full- and half-duplex operation ? statistics counter registers ? mii/rmii interface to the physical layer ? interrupt genera tion to signal receive an d transmit completion ? dma master on receive and transmit channels ? transmit and receive fifos ? automatic pad and crc generation on transmitted frames ? automatic discard of frames received with errors ? address checking logic supports up to four specific 48-bit addresses ? supports promiscuous mode where all vali d received frames are copied to memory ? hash matching of unicast and multicast destination addresses ? external address matching of received frames ? physical layer management through mdio interface ? half-duplex flow control by forcing collisions on incoming frames ? full-duplex flow control with recognition of incoming pause frames and hardware generation of transmitted pause frames ? support for 802.1q vlan tagging with recognition of incoming vlan and priority tagged frames ? multiple buffers per receive and transmit frame ? wake-on-lan support ? jumbo frames up to 10240 bytes supported 24.2 overview the macb module implements a 10/100 ethernet mac compatible with the ieee 802.3 stan- dard using an address checker, statistics and control registers, receive and transmit sub- modules, and a dma interface. the address checker recognizes four specific 48-bit addresses and contains a 64-bit hash regis- ter for matching multicast and unicast addresses. it can recognize the broadcast address of all ones, copy all frames, and act on an external address match signal. the statistics register sub-module contains register s for counting various types of events associ- ated with transmit and receive operations. these registers, along with the status words stored in the receive buffer list, enable software to generate network management statistics compatible with ieee 802.3.
489 32117b?avr-03/11 at32uc3c 24.3 block diagram figure 24-1. macb block diagram 24.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 24.4.1 i/o lines the pins used for interfacing the macb may be multiplexed with the i /o controller lines. the programmer must first program the i/o controlle r to assign the desired macb pins to their peripheral function. if i/o lines of the macb are no t used by the application, they can be used for other purposes by the i/o controller. 24.4.2 power management if the cpu enters a sleep mode that disables clocks used by the macb, the macb will stop functioning and resume operation after the system wakes up from sleep mode. to prevent bus errors the macb operation must be terminated before entering sleep mode. 24.4.3 clocks the clocks for the macb bus interface (c lk_macb_pb/clk_macb_hsb) are generated by the power manager. these clocks are enabled at reset, and can be disabled in the power man- register interface address checker statistics registers control registers ethernet receive ethernet transmit dma interface rx fifo tx fifo high speed bus master peripheral bus slave mdio mii/rmii
490 32117b?avr-03/11 at32uc3c ager. it is recommended to disable the macb befo re disabling the clocks, to avoid freezing the macb in an undefined state. the synchronization module in the macb requires that the bus clock (clk_macb_hsb) runs on at least the speed of the macb_tx/rx_clk, which is 25mhz in 100mbps, and 2.5mhz in 10mbps in mii mode and 50mhz in 100mbps, and 5mhz in 10mbps in rmii mode. 24.4.4 interrupt the macb interrupt request line is connected to the interrupt controller. using the macb inter- rupt requires the interrupt controller to be programmed first. 24.4.5 debug operation when an external debugger forces the cpu into debug mode, the macb continues normal operation. if the macb is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. 24.5 functional description the control registers drive the mdio interface, setup dma activity, start frame transmission and select modes of operation such as full or half-duplex. the receive sub-module checks for valid preamble, frame check sequence (fcs), alignment and length, and presents received frames to the address checking sub-module and dma interface. the transmit sub-module takes data from the dma interface, adds preamble and, if necessary, pad and fcs, and transmits data according to the carr ier sense multiple access with collision detect (csma/cd) protocol. the start of trans mission is deferred if carrier sense (crs) is active. if collision (col) becomes active during trans mission, a jam sequence is asserted and the transmission is retried after a random back off. crs and col have no effect in full duplex mode. the dma interface can access external memory through its high speed bus (hsb). it contains receive and transmit fifos for buffering frame data. it loads the transmit fifo and empties the receive fifo using hsb bus master operations. received data is not sent to memory until the address checking logic has determined that the frame should be copied. received or transmit- ted frames are stored in one or more buffers. receive buffers have a fixed length of 128 bytes. transmit buffers range in length between 0 and 2047 bytes, and up to 128 buffers are allowed per frame. the dma interface manages the transmit and receive frame buffer queues. these queues can hold multiple frames. 24.5.1 memory interface frame data is transferred to and from the macb by the dma interface. all transfers are 32-bit words and may be single accesses or bursts of 2, 3 or 4 words. burst accesses do not cross six- teen-byte boundaries. bursts of 4 words are the default data transfer; single accesses or bursts of less than four words may be used to transfer data at the beginning or the end of a buffer. the dma interface performs six types of operation on the bus. in order of priority, these are: 1. receive buffer manager write 2. receive buffer manager read
491 32117b?avr-03/11 at32uc3c 3. transmit data dma read 4. receive data dma write 5. transmit buffer manager read 6. transmit buffer manager write 24.5.2 fifo fifo depths are 124 bytes. data is typically transferred in and out of the fifos in bursts of four words. in reception, a bus request is asserted when the fifo contains four words and has space for three more. for trans- mission, a bus request is generated when there is space for four words, or when there is space for two words if the next transfer is only one or two words. thus the bus latency is less than the time it takes to load the fifo and transmit or receive three words (12 bytes) of data. at 100 mbit/s, it takes 960 ns to transmit or receive 12 bytes of data. in addition, six pb clock cycles should be allowed for data to be loaded from the bus and to propagate through the fifos. for a 60 mhz pb clock this takes 100 ns, making the bus latency requirement 860 ns. 24.5.3 receive buffers received frames, optionally including crc/fcs, ar e written to receive buffers stored in mem- ory. each receive buffer size is 128 bytes. the start location for each receive buffer is stored in memory in a list of receive buffer descriptors at a location pointed to by the receive buffer queue pointer register. the receive buffer start location is a word address. for the first buffer of a frame, the start location can be offset by up to three bytes depending on the value written to bits 14 and 15 of the network configuration register. if the start location of the buffer is offset the available length of the first buffer of a frame is reduced by the corresponding number of bytes. each list entry consists of two words, the first being the address of the receive buffer and the second being the receive status. if the length of a receive frame exceeds the buffer length, the status word for the used buffer is written with zer oes except for the ?start of frame? bit and the offset field, if appropriate. bit zero of the address field is written to one to show the buffer has been used. the receive buffer manager then reads the location of the next receive buffer and fills that with receive frame data. the final buff er descriptor status word contains the complete frame status. refer to table 24-1 for details of the receive buffer descriptor list. table 24-1. receive buffer descriptor entry bit function word 0 31:2 address of beginning of buffer 1 wrap - marks last descriptor in receive buffer descriptor list. 0 ownership - needs to be zero for the macb to write data to the receive buffer. the macb sets this to one once it has successfully written a frame to memory. software has to clear this bit before the buffer can be used again. word 1 31 global all ones broadcast address detected 30 multicast hash match 29 unicast hash match
492 32117b?avr-03/11 at32uc3c to receive frames, the buffer descriptors must be initialized by writing the right address to bits 2 through 31in the first word of each list entry. bit zero must be written with zero. bit one is the wrap bit and indicates the last entry in the list. the start location of the receive buffer descriptor list must be written to the receive buffer queue pointer register before setting the receive enable bit in the network control register to enable receive. as soon as the receive sub-module starts writing received frame data to the receive fifo, the receive buffer manager reads the first receive buffer location pointed to by the receive buffer queue pointer register. if the filter sub-module indicates that the frame should be copied to memory, the receive data dma operation starts writing data into the receive buffer. if an error occurs, the buffer is recov- ered. if the current buffer pointer has its wrap bit set or is the 1024 th descriptor, the next receive buffer location is read from the beginning of the receive descriptor list. otherwise, the next receive buffer location is read from the next word in memory. there is an 11-bit counter to count out the 2048 word locations of a maximum length, receive buffer descriptor list. this is added with the valu e originally written to the receive buffer queue pointer register to produce a pointer into the list. a read of the receive buffer queue pointer reg- ister returns the pointer value, which is the queue entry currently being accessed. the counter is reset after receive status is written to a descript or that has its wrap bit set or rolls over to zero after 1024 descriptors have been accessed. the value written to the receive buffer pointer regis- ter may be any word-aligned address, provided that there are at least 2048 word locations available between the pointer and the top of the memory. 28 external address match 27 reserved for future use 26 specific address register 1 match 25 specific address register 2 match 24 specific address register 3 match 23 specific address register 4 match 22 type id match 21 vlan tag detected (i.e., type id of 0x8100) 20 priority tag detected (i.e., type id of 0x8100 and null vlan identifier) 19:17 vlan priority (only valid if bit 21 is set) 16 concatenation format indicator (cfi) bit (only valid if bit 21 is set) 15 end of frame - when set the buffer contains the end of a frame. if end of frame is no t set, then the only other valid status are bits 12, 13 and 14. 14 start of frame - when set the buffer contains the start of a frame. if both bits 15 a nd 14 are set, then the buffer contains a whole frame. 13:12 receive buffer offset - indicates the number of bytes by which the data in the first buffer is offset from the word address. updated with the current values of the network configuration register. if jum bo frame mode is enabled through bit 3 of the network configuration register, then bits 12 and 13 of the rece ive buffer descriptor entry are used to indicate bits 12 and 13 of the frame length. 11:0 length of frame including fcs (if selected). bits 12 and 13 are also used if jumbo frame mode is selected. table 24-1. receive buffer descrip tor entry (continued) bit function
493 32117b?avr-03/11 at32uc3c the system bus specification requires that bursts should not cross 1k boundaries. as receive buffer manager writes are bursts of two words, to ensure that this does not occur, it is best to write the pointer register with the least three signi ficant bits set to zero. as receive buffers are used, the receive buffer manager sets bit zero of the first word of the descriptor to indicate used . if a receive error is detected the receive buffer currently being written is recovered. previous buf- fers are not recovered. software should search through the used bits in the buffer descriptors to find out how many frames have been received. it should be checking the start-of-frame and end- of-frame bits, and not rely on the value returned by the receive buffer queue pointer register which changes continuously as more buffers are used. for crc errored frames, excessive length frames or length field mismatched frames, all of which are counted in the statistics registers, it is possible that a frame fragment might be stored in a sequence of receive buffers. software can detect this by looking for start of frame bit set in a buffer following a buffer with no end of frame bit set. for a properly working ethernet system, there should be no excessively long frames or frames greater than 128 bytes with crc/ fcs errors. collision fragments are less than 128 bytes long. therefore, it is a rare occurrence to find a frame fragment in a receive buffer. if bit zero is set when the receive buffer manager reads the location of the receive buffer, then the buffer has already been used and cannot be used again until software has processed the frame and cleared bit zero. in this case, the dma interface sets the buffer not available bit in the receive status register and triggers an interrupt. if bit zero is set when the receive buffer manager reads the location of the receive buffer and a frame is being received, the frame is discarded and the receive resource error statistics register is incremented. a receive overrun condition occurs when bus was not granted in time or because hresp was not ok (bus error). in a receive overrun conditi on, the receive overrun interrupt is asserted and the buffer currently being written is recovered. the next frame received with an address that is recognized reuses the buffer. if bit 17 of the network configuration register is set, the fcs of received frames shall not be cop- ied to memory. the frame length indicated in the receive status field shall be reduced by four bytes in this case. 24.5.4 transmit buffer frames to be transmitted are stored in one or more transmit buffers. transmit buffers can be between 0 and 2047 bytes long, so it is possible to transmit frames longer than the maximum length specified in ieee standard 802.3. zero length buffers are allowed. the maximum number of buffers permitted for each transmit frame is 128. the start location for each transmit buffer is stored in memory in a list of transmit buffer descrip- tors at a location pointed to by the transmit buffer queue pointer register. each list entry consists of two words, the first being the byte address of the transmit buffer and the second containing the transmit control and status. frames can be transmitted with or without automatic crc gen- eration. if crc is automatically generated, padding is also automatically generated to take frames to a minimum length of 64 bytes. table 24-2 on page 494 defines an entry in the transmit buffer descriptor list. to transmit frames, the buffer descriptors must be initialized by writing the right byte address to bits 0 through 31 in the first word of each list entry. the second transmit buffer descriptor is initialized with control information that indicates the length of the buffer,
494 32117b?avr-03/11 at32uc3c whether or not it is to be transmitted with crc and whether the buffer is the last buffer in the frame. after transmission, the control bits are written back to the second word of the first buffer along with the ?used? bit and other status information. before a transmission, bit 31 is the ?used? bit which must be zero when the control word is read. it is written to one when a frame has been transmitted. bits 27, 28 and 29 indicate various transmit error conditions. bit 30 is the ?wrap? bit which can be set for any buffer within a frame. if no wrap bit is encountered after 1024 descrip- tors, the queue pointer rolls over to the start. the transmit buffer queue pointer register must not be written while transmit is active. if a new value is written to the transmit buffer queue pointer register, the queue pointer resets itself to point to the beginning of the new queue. if transmit is disabled by writing to bit 3 of the network control, the transmit buffer queue pointer register resets to point to the beginning of the transmit queue. note that disabling receive does not have the same effect on the receive queue pointer. once the transmit queue is init ialized, transmit is activate d by writing to bit 9, the transmit start bit of the network control register. transmit is halted when a buffer descriptor with its used bit set is read, or if a transmit error occurs, or by writ ing to the transmit halt bit of the network control register. (transmission is suspended if a pause frame is received while the pause enable bit is set in the network configuration register.) rewrit ing the start bit while transmission is active is allowed. transmission control is implemented with a tx_go variable which is readable in the transmit sta- tus register at bit location 3. the tx_go variable is reset when: ? transmit is disabled ? a buffer descriptor with its ownership bit set is read ? a new value is written to the transmit buffer queue pointer register ? bit 10, tx_halt, of the network control register is written ? there is a transmit error such as too many retries or a transmit underrun. to set tx_go, write to bit 9, tx_start, of the network control register. transmit halt does not take effect until any ongoing transmit finishes. if a collision occurs du ring transmission of a multi-buf- fer frame, transmission automatically restarts from the first buffer of the frame. if a ?used? bit is read midway through transmission of a multi-buffer frame, this is treated as a transmit error. transmission stops, tx_er is asserted and the fcs is bad. if transmission stops due to a transmit error, the transmit queue pointer resets to point to the beginning of the transmit queue. software needs to re-initialize the transmit queue after a trans- mit error. if transmission stops due to a ?used? bit being read at the start of the frame, the transmission queue pointer is not reset and transmit starts from the same transmit buffer descriptor when the transmit start bit is written table 24-2. transmit buffer descriptor entry bit function word 0 31:0 byte address of buffer word 1
495 32117b?avr-03/11 at32uc3c 24.5.5 transmit sub-module this sub-module transmits frames in accordance with the ethe rnet ieee 802.3 csma/cd proto- col. frame assembly starts by adding preamble and the start frame delimiter. data is taken from the transmit fifo a word at a time. data is transmitted least significant nibble first. if necessary, padding is added to increase the frame length to 60 bytes. crc is calculated as a 32-bit polyno- mial. this is inverted and appended to the end of the frame, taking the frame length to a minimum of 64 bytes. if the no crc bit is set in the second word of the last buffer descriptor of a transmit frame, neither pad nor crc are appended. in full-duplex mode, frames are transmitted immediately. back-to-back frames are transmitted at least 96 bit times apart to guarantee the interframe gap. in half-duplex mode, the transmitter checks carrier sense. if asserted, it waits for it to de-assert and then starts transmission afte r the interframe gap of 96 bit times. if the collision signal is asserted during transmission, the transmitter transmits a jam sequence of 32 bits taken from the data register and retries transmission after the back off time has elapsed. the back-off time is based on an xor of the 10 least significant bits of the data coming from the transmit fifo and a 10-bit pseudo random number. the number of bits used depends on the number of collisions seen. after the first collision, 1 bit is used, after the second 2, and so on up to 10. above 10, all 10 bits are used. an error is indicated and no further attempts are made if 16 attempts cause collisions. if transmit dma underruns, bad crc is automa tically appended using the same mechanism as jam insertion and tx_er is asserted. in a properly configured system, this should never happen. if the back pressure bit is set in the network control register in half duplex mode, the transmit sub-module transmits 64 bits of data, which can co nsist of 16 nibbles of 1011 or in bit-rate mode 31 used. needs to be zero for the macb to read data from the tran smit buffer. the macb sets this to one for the first buffer of a frame once it has been successfully transmitted. software has to clear this bit before the buffer can be used again. note: this bit is only set for the first buffer in a frame unlike receive where all buffers have the used bit set once used. 30 wrap. marks last descriptor in transmit buffer descriptor list. 29 retry limit exceeded, transmit error detected 28 transmit underrun, occurs either when hresp is not ok (bus error) or the transmit data could not be fetched in time or when buffers are exhausted in mid frame. 27 buffers exhausted in mid frame 26:17 reserved 16 no crc. when set, no crc is appended to the current frame. this bit only needs to be set for the last buffer of a frame. 15 last buffer. when set, this bit indicates the last buffer in the current frame has been reached. 14:11 reserved 10:0 length of buffer table 24-2. transmit buffer descrip tor entry (continued) bit function
496 32117b?avr-03/11 at32uc3c 64 1s, whenever it sees an in coming frame to force a collision. this provides a way of imple- menting flow control in half-duplex mode. 24.5.6 pause frame support the start of an 802.3 pause frame is as follows: the network configuration register contains a receive pause enable bit (13). if a valid pause frame is received, the pause time register is updated with the frame?s pause time, regardless of its current contents and regardless of the state of the configuration register bit 13. an interrupt (12) is triggered when a pause frame is received, assuming it is enabled in the interrupt mask register. if bit 13 is set in the network configuration register and the value of the pause time reg- ister is non-zero, no new frame is transmitted until the pause time register has decremented to zero. the loading of a new pause time, and hence the pausing of transmission, only occurs when the macb is configured for full-duplex operation. if the macb is configured for half-duplex, there is no transmission pause, but the pause frame received interrupt is st ill triggered. a valid pause frame is defined as having a destin ation address that matches either the address stored in specific address register 1 or matches 0x0180c2000001 and has the mac control frame type id of 0x8808 and the pause opcode of 0x0001. pause frames that have fcs or other errors are treated as invalid and are discarded. valid pause frames received increment the pause frame received statistic register. the pause time register decrements every 512 bit times (i.e., 128 rx_clk in nibble mode) once transmission has stopped. for te st purposes, the register decr ements every rx_clk cycle once transmission has stopped if bit 12 (r etry test) is set in the network configuration register. if the pause enable bit (13) is not set in the network configuration register, then the decrementing occurs regardless of whether transmission has stopped or not. an interrupt (13) is asserted whenever the pause time register decrements to zero (assuming it is enabled in the interrupt mask register). auto matic transmission of pause frames is supported through the transmit pause frame bits of the network control register and the tx_pause and tx_pause_zero inputs. if either bit 11 or bit 12 of the network control register is written to with a 1, or if the input signal tx_pause is toggled, a pause frame is transmitted only if full duplex is selected in the network configuration register and transmit is enabled in the network control register. pause frame transmission occurs immediately if transmit is inactive or if transmit is active between the current frame and the next frame due to be transmitted. the transmitted pause frame is comprised of the items in the following list: ? a destination address of 01-80-c2-00-00-01 ? a source address taken from the specific address 1 register ? a type id of 88-08 (mac control frame) ? a pause opcode of 00-01 ? a pause quantum table 24-3. start of an 802.3 pause frame destination address source address type (mac control frame) pause opcode pause time 0x0180c2000001 6 bytes 0x8808 0x0001 2 bytes
497 32117b?avr-03/11 at32uc3c ? fill of 00 to take the frame to minimum frame length ? valid fcs the pause quantum used in the generated frame depends on the trigger source for the frame as follows: 1. if bit 11 is written with a one, the pause quantum comes from the transmit pause quan- tum register. the transmit pause quantum register resets to a value of 0xffff giving a maximum pause quantum as a default. 2. if bit 12 is written with a one, the pause quantum is zero. 3. if the tx_pause input is toggled and the tx_pause_zero input is held low until the next toggle, the pause quantum comes from the transmit pause quantum register. 4. if the tx_pause input is toggled and the tx_pause_zero input is held high until the next toggle, the pause quantum is zero. after transmission, no interrupts are generated and the only statistics register that is incre- mented is the pause frames transmitted register. 24.5.7 receive sub-module the receive sub-module checks for valid prea mble, fcs, alignment and length, presents received frames to the dma interface and stores the frames destination address for use by the address checking sub-module. if, during frame reception, the frame is found to be too long or rx_er is asserted, a bad frame indication is sent to the dma interface. the dma interface then stops sending data to memory. at the end of frame reception, the receive sub-module indicates to the dma interface whether the frame is good or bad. the dma interface recovers the current receive buffer if the frame was bad. the receive sub-module signals the register sub-module to increment the alignment error, the crc (fcs) error, the short frame, long frame, jabber error, the receive symbol error statistics and the length field mismatch statistics. the enable bit for jumbo frames in the network configuration register allows the macb to receive jumbo frames of up to 10240 bytes in size. this operation does not form part of the ieee802.3 specification and is disabled by default. when ju mbo frames are enabled, frames received with a frame size greater than 10240 bytes are discarded. 24.5.8 address checking sub-module the address checking (or filter) sub-module indicates to the dma interface which receive frames should be copied to memory. whether a frame is copied depends on what is enabled in the net- work configuration register, the state of the external match pin, the contents of the specific address and hash registers and the frame?s destinati on address. in this implementation of the macb, the frame?s source address is not checked. if bit 18 of the network configuration register is not set, a frame is not copied to memory if the macb is transmitting in half duplex mode at the time a destination address is received. if bit 18 of the network configuration register is set, frames can be received while transmitting in half-duplex mode. ethernet frames are transmitted a byte at a time, least significant bit first. the first six bytes (48 bits) of an ethernet frame make up the destination address. the first bit of the destination address, the lsb of the first byte of the frame, is the group/individual bit: this is one for multicast addresses and zero for unicast. the all ones address is the broadcast address, and a special case of multicast. the macb supports recognition of four specific addresses. each specific address requires two registers, specific address register bottom and specific address register top. specific address
498 32117b?avr-03/11 at32uc3c register bottom stores the first four bytes of the destination address and specific address register top contains the last two bytes. the addresses st ored can be specific, group, local or universal. the destination address of received frames is compared against the data stored in the specific address registers once they have been activated. the addresses are deactivated at reset or when their corresponding specific a ddress register bottom is written. they are activated when specific address register top is written. if a receive frame address ma tches an active address, the frame is copied to memory. the following example illustrates the use of the address match registers for a mac address of 21:43:65:87:a9:cb. preamble 55 sfd d5 da (octet0 - lsb) 21 da(octet 1) 43 da(octet 2) 65 da(octet 3) 87 da(octet 4) a9 da (octet5 - msb) cb sa (lsb) 00 sa 00 sa 00 sa 00 sa 00 sa (msb) 43 sa (lsb) 21 the sequence above shows the beginning of an et hernet frame. byte order of transmission is from top to bottom as shown. for a successful match to specific address 1, the following address matching registers must be set up: ? base address + 0x98 0x87654321 (bottom) ? base address + 0x9c 0x0000cba9 (top) and for a successful match to the type id register, the following should be set up: ? base address + 0xb8 0x00004321 24.5.9 broadcast address the broadcast address of 0xffffffffffff is recognized unless the ?no broadcast? bit in the network configuration register is set. 24.5.10 hash addressing the hash address register is 64 bits long and ta kes up two locations in the memory map. the least significant bits are stored in hash register bottom and the most significant bits in hash reg- ister top.
499 32117b?avr-03/11 at32uc3c the unicast hash enable and the multicast hash enab le bits in the network configuration register enable the reception of hash matched frames. the destination address is reduced to a 6-bit index into the 64-bit hash register using the following hash function. the hash function is an exclusive or of every sixth bit of the destination address. hash_index[5] = da[5] ^ da[11] ^ da[17] ^ da[23] ^ da[29] ^ da[35] ^ da[41] ^ da[47] hash_index[4] = da[4] ^ da[10] ^ da[16] ^ da[22] ^ da[28] ^ da[34] ^ da[40] ^ da[46] hash_index[3] = da[3] ^ da[09] ^ da[15] ^ da[21] ^ da[27] ^ da[33] ^ da[39] ^ da[45] hash_index[2] = da[2] ^ da[08] ^ da[14] ^ da[20] ^ da[26] ^ da[32] ^ da[38] ^ da[44] hash_index[1] = da[1] ^ da[07] ^ da[13] ^ da[19] ^ da[25] ^ da[31] ^ da[37] ^ da[43] hash_index[0] = da[0] ^ da[06] ^ da[12] ^ da[18] ^ da[24] ^ da[30] ^ da[36] ^ da[42] da[0] represents the least significant bit of the first byte received, that is , the multicast/unicast indicator, and da[47] represents the most significant bit of the last byte received. if the hash index points to a bit that is set in the hash register, then the frame is matched accord- ing to whether the frame is multicast or unicast. a multicast match is signalled if the multicast hash enable bit is set. da[0] is 1 and the hash index points to a bit set in the hash register. a unicast match is signalled if the unicast hash enable bit is set. da[0] is 0 and the hash index points to a bit set in the hash register. to receive all multicast frames, the hash register should be set with all ones and the multicast hash enable bit should be set in the network configuration register. 24.5.11 external address matching the external address signal (eam) is enabled by bit 9 in the network configuration register. when enabled, the filter sub-module sends the store frame and the external address match sta- tus signal to the dma interface if the external address match signal is asserted (from a source external to the macb) and the destination addr ess has been received and the frame has not completed. for the dma interface to be able to copy the frame to memory, the external address signal must be asserted before four words have been loaded into the receive fifo. 24.5.12 copy all frames (or promiscuous mode) if the copy all frames bit is set in the network configuration register, then all non-errored frames are copied to memory. for example, frames that are too long, too short, or have fcs errors or rx_er asserted during reception are discarded and all others are received. frames with fcs errors are copied to memory if bit 19 in the network configuration register is set. 24.5.13 type id checking the contents of the type_id register are compared against the length/type id of received frames (i.e., bytes 13 and 14). bit 22 in the receive buffer descriptor status is set if there is a match. the reset state of this register is zero which is unlikely to match the length/type id of any valid ether- net frame. note: a type id match does not affect whether a frame is copied to memory.
500 32117b?avr-03/11 at32uc3c 24.5.14 vlan support an ethernet encoded 802.1q vlan tag looks like this: the vlan tag is inserted at the 13 th byte of the frame, adding an extra four bytes to the frame. if the vid (vlan identifier) is null (0x000), this indicates a priority-tagged frame. the mac can support frame lengths up to 1536 bytes, 18 byte s more than the original ethernet maximum frame length of 1518 bytes. this is achieved by setting bit 8 in the network configuration register. the following bits in the receive buffer descrip tor status word give information about vlan tagged frames: ? bit 21 set if receive frame is vlan tagged (i.e. type id of 0x8100) ? bit 20 set if receive frame is priority tagged (i.e. type id of 0x8100 and null vid). (if bit 20 is set bit 21 is set also.) ? bit 19, 18 and 17 set to priority if bit 21 is set ? bit 16 set to cfi if bit 21 is set 24.5.15 wake-on lan support the receive module supports wake-on lan by detecting the following events on incoming receive frames: ? magic packet ? arp request to the device ip address ? specific address 1 filter match ? multicast hash filter match if one of these events occurs wake-on lan detection is indicated by asserting wol output pin for 64 rx_clk cycles. these events can be indivi dually enabled by bits mag, arp, sa1 & mti in wake-on lan register (wol). also, for wake-on lan detection to occur, receive enable must be set in the network control register (ncr), however a receive buffer does not have to be available. wol assertion due to arp request, specific address 1 or multicast filter events will occur even if the frame is errored. for magic packet event, the frame must be correctly formed and error free. a magic packet event is detected if all of the following are true: ? magic packet events are enabled by wol.mag bit ? the frame?s destination address matches specific address 1 ? the frame is correctly formed with no errors ? the frame contains at least 6 bytes of 0xff for synchronization ? there are 16 repetitions of the contents of specific address 1 register immediately following the synchronization an arp packet event is detected if all of the following are true: ? arp request are enabled by wol.arp bit ? broadcasts are allowed by ncfg.caf table 24-4. 802.1q vlan tag tpid (tag protocol identifier) 16 bi ts tci (tag control information) 16 bits 0x8100 first 3 bits priority, then cfi bit, last 12 bits vid
501 32117b?avr-03/11 at32uc3c ? the frame has a broadcast destination address (bytes 1 to 6) ? the frame has a typeid field of 0x0806 (bytes 13 and 14) ? the frame has an arp operation field of 0x0001 (bytes 21 and 22) ? the least significant 16 bits of the frame arp target protocol (bytes 41 and 42) match the value written in wol.ip. the decoding of the arp fields adjusts automatically if a vlan tag is detected within the frame. the reserved value of 0x0000 for wake-on lan target addre ss value will not cause an arp request event, even if matched by the frame. a specific address 1 filter match event will occur if all of the following are true: ? specific address 1 events are enabled by wol.sa1 bit ? the frame destination address matches the value programmed in the specific address 1 registers a multicast filter match event will o ccur if all of the following are true: ? multicast hash events are enabled by wol.mti bit ? multicast hash filtering is enabled by ncfg.mti bit ? the frame destination address matches against the multicast hash filter ? the frame destination address is not a broadcast 24.5.16 phy maintenance the register man enables the macb to communi cate with a phy by means of the mdio inter- face. it is used during auto-negotiation to ensure that the macb and the phy are configured for the same speed and duplex configuration. the phy maintenance register is implemented as a shift register. writing to the register starts a shift operation which is signalled as complete when bit two is set in the network status register (about 2000 mck cycles later when bit ten is set to zero, and bit eleven is set to one in the net- work configuration register). an interrupt is generated as this bit is set. during this time, the msb of the register is output on the mdio pin and the lsb updated from the mdio pin with each divided pb clock (dpc) cycle. this causes transmission of a phy management frame on mdio. reading during the shift operation returns the current contents of the shift register. at the end of management operation, the bits have shifted back to their original locations. for a read opera- tion, the data bits are updated with data read from the phy. it is important to write the correct values to the register to ensure a valid phy management frame is produced. the mdio interface can read ieee 802.3 clause 45 phys as well as clause 22 phys. to read clause 45 phys, bits [31:28] should be written to 0x0011. for a description of dpc generation, see the network configuration register in section ?network configuration register? on page 510 . 24.5.17 media independent interface the ethernet mac is capable of interfacing to both rmii and mii interfaces. the rmii bit in the usrio register controls the interface that is sele cted. when this bit is set, the rmii interface is selected, else the mii interface is selected.
502 32117b?avr-03/11 at32uc3c the mii and rmii interface are capable of both 10mb/s and 100mb/s data rates as described in the ieee 802.3u standard. the signals used by the mii and rmii interfaces are described in table 24-5 . the intent of the rmii is to provide a reduced pin count alternative to the ieee 802.3u mii. it uses 2 bits for transmission (txd[1:0]) and two bits for reception (rxd[1:0]). there are transmit enable (tx_en), a receive error (rx_er), a carrier sense (crs), and a 50 mhz reference clock (tx_clk) for 100mb/s data rate. 24.5.17.1 rmii transmit and receive operation the same signals are used internally for both the rmii and the mii operations. the rmii maps these signals in a more pin-efficient manner. the transmit and receive bits are converted from a 4-bit parallel format to a 2-bit parallel scheme that is clocked at twice the rate. the carrier sense and data valid signals are combined into the rx_d v signal. this signal contains information on carrier sense, fifo status, a nd validity of the data. transmit error bit (tx_er) and collision detect (col) are not used in rmii mode. table 24-5. pin configuration pin name mii rmii tx_clk transmit clock reference clock crs carrier sense col collision detect rx_dv data valid carrier sense/data valid rxd[3:0] rxs[3:0] 4-bit receive data rxd[1:0] 2-bit receive data rx_er receive error receive error rx_clk receive clock tx_en transmit enable transmit enable txd[3:0] txd[3:0] 4-bit transmit data txd[1:0] 2-bit transmit data tx_er transmit error
503 32117b?avr-03/11 at32uc3c 24.6 programming interface 24.6.1 configuration initialization of the macb configuration (e.g. frequency ratios) must be done while the transmit and receive circuits are disabled. network control register and network configuration register are described below. 24.6.2 receive buffer list receive data is written to areas of data (i.e., buffers) in system memory. these buffers are listed in another data structure that also resides in main memory. this data structure (receive buffer queue) is a sequence of descriptor entries as defined in ?receive buffer descriptor entry? on page 491 . it points to this data structure. figure 24-2. receive buffer list to create the list of buffers: 1. allocate a number ( n ) of buffers of 128 bytes in system memory. 2. allocate an area 2 n words for the receive buffer descriptor entry in system memory and create n entries in this list. mark all entries in th is list as owned by macb, i.e., bit 0 of word 0 set to 0. 3. if less than 1024 buffers are defined, the last descriptor must be marked with the wrap bit (bit 1 in word 0 set to 1). 4. write address of receive buffer descriptor entry to macb register receive buffer queue pointer. 5. the receive circuits can then be enabled by writing to the address recognition registers and then to the network control register. receive buffer queue pointer (mac register) receive buffer 0 receive buffer 1 receive buffer description list (in memory) (in memory) receive buffer n
504 32117b?avr-03/11 at32uc3c 24.6.3 transmit buffer list transmit data is read from the system memory these buffers are listed in another data structure that also resides in main memory. this data st ructure (transmit buffer queue) is a sequence of descriptor entries (as defined in table 24-2 on page 494 ) that points to this data structure. to create this list of buffers: 1. allocate a number ( n ) of buffers of between 1 and 2047 bytes of data to be transmitted in system memory. up to 128 buffers per frame are allowed. 2. allocate an area 2 n words for the transmit buffer descriptor entry in system memory and create n entries in this list. mark all entrie s in this list as owned by macb, i.e. bit 31 of word 1 set to 0. 3. if fewer than 1024 buffers are defined, the last descriptor must be marked with the wrap bit (bit 30 in word 1 set to 1). 4. write address of transmit buffer descriptor entry to macb register transmit buffer queue pointer. 5. the transmit circuits can then be enabled by writing to the network control register. 24.6.4 address matching the macb register-pair hash address and the four specific address register-pairs must be writ- ten with the required values. each register-pair comprises a bottom register and top register, with the bottom register being written first. the addre ss matching is disabled for a particular reg- ister-pair after the bottom-register has been written and re-enabled when the top register is written. see section ?24.5.8? on page 497. for details of address matching. each register-pair may be written at any time, regardless of whether the receive circuits are enabled or disabled. 24.6.5 interrupts there are 14 interrupt conditions that are detected within the macb. these are ored to make a single interrupt. this interrupt is handled by the interrupt controller. on receipt of the interrupt signal, the cpu enters the interrupt handler. to ascertain which interrupt has been generated, read the interrupt status register. note that this re gister clears itself when read. at reset, all inter- rupts are disabled. to enable an interrupt, write to interrupt enable register with the pertinent interrupt bit set to 1. to disable an interrupt, write to interrupt disable register with the pertinent interrupt bit set to 1. to check whether an interrupt is enabled or disabled, read interrupt mask register: if the bit is set to 1, the interrupt is disabled. 24.6.6 transmitting frames to set up a frame for transmission: 1. enable transmit in the network control register. 2. allocate an area of system memory for transmit data. this does not have to be contigu- ous, varying byte lengths can be used as long as they conclude on byte borders. 3. set-up the transmit buffer list. 4. set the network control register to enable transmission and enable interrupts. 5. write data for transmission into these buffers. 6. write the address to transmit buffer descriptor queue pointer. 7. write control and length to word one of the transmit buffer descriptor entry. 8. write to the transmit start bit in the network control register.
505 32117b?avr-03/11 at32uc3c 24.6.7 receiving frames when a frame is received and the receive circuits are enabled, the macb checks the address and, in the following cases, the frame is written to system memory: ? if it matches one of the four specific address registers. ? if it matches the hash address function. ? if it is a broadcast address (0xf fffffffffff) and broadcasts are allowed. ? if the macb is configured to copy all frames. ? if the eam is asserted before four words have been loaded into the receive fifo. the register receive buffer queue pointer points to the next entry (see table 24-1 on page 491 ) and the macb uses this as the address in system memory to write the frame to. once the frame has been completely and successfully received an d written to system memory, the macb then updates the receive buffer descriptor entry with the reason for the address match and marks the area as being owned by software. once this is complete an interrupt re ceive complete is set. software is then responsible for handling the data in the buffer and then releasing the buffer by writing the ownership bit back to 0. if the macb is unable to write the data at a rate to match the incoming frame, then an interrupt receive overrun is set. if there is no receive buffer available, i.e., the next buffer is still owned by software, the interrupt receive buffer not avail able is set. if the frame is not successfully received, a statistic register is incremented and the frame is discarded without informing software.
506 32117b?avr-03/11 at32uc3c 24.7 user interface table 24-6. macb register memory map offset register register name access reset 0x00 network control register ncr read/write 0x00000000 0x04 network configuration register ncfg read/write 0x00008000 0x08 network status register nsr read-only - 0x14 transmit status regi ster tsr read/write 0x00000000 0x18 receive buffer queue pointer register rbqp read/write 0x00000000 0x1c transmit buffer queue pointer register tbqp read/write 0x00000000 0x20 receive status regist er rsr read/write 0x00000000 0x24 interrupt status register isr read/write 0x00000000 0x28 interrupt enable register ier write-only 0x00000000 0x2c interrupt disable register idr write-only 0x00000000 0x30 interrupt mask register imr read-only 0x00003fff 0x34 phy maintenance register man read/write 0x00000000 0x38 pause time register ptr read/write 0x00000000 0x3c pause frames received register pfr read/write 0x00000000 0x40 frames transmitted ok r egister fto read/write 0x00000000 0x44 single collision frames register scf read/write 0x00000000 0x48 multiple collision frames register mcf read/write 0x00000000 0x4c frames received ok register fro read/write 0x00000000 0x50 frame check sequence errors register fcse read/write 0x00000000 0x54 alignment errors register ale read/write 0x00000000 0x58 deferred transmission frames register dtf read/write 0x00000000 0x5c late collisions register lcol read/write 0x00000000 0x60 excessive collisions register excol read/write 0x00000000 0x64 transmit underrun errors register tund read/write 0x00000000 0x68 carrier sense errors register cse read/write 0x00000000 0x6c receive resource errors register rre read/write 0x00000000 0x70 receive overrun errors register rov read/write 0x00000000 0x74 receive symbol errors register rse read/write 0x00000000 0x78 excessive length errors register ele read/write 0x00000000 0x7c receive jabbers register rja read/write 0x00000000 0x80 undersize frames register usf read/write 0x00000000 0x84 sqe test errors register ste read/write 0x00000000 0x88 received length field mismatch register rle read/write 0x00000000 0x8c transmitted pause frames register tpf read/write 0x00000000 0x90 hash register bottom hrb read/write 0x00000000
507 32117b?avr-03/11 at32uc3c statistics registers (pfr to tpf) should be read frequently enough to prevent loss of data. the receive statistics registers are only incremented when the receive enable bit is set in the network control register (ncr.re). write access to statistics registers is allowed if ncr.westat is set. statistic registers are cleared on a read and stick at all ones when they count to their maximum value. 0x94 hash register top hrt read/write 0x00000000 0x98 specific address 1 bottom register sa1b read/write 0x00000000 0x9c specific address 1 top register sa1t read/write 0x00000000 0xa0 specific address 2 bottom register sa2b read/write 0x00000000 0xa4 specific address 2 top register sa2t read/write 0x00000000 0xa8 specific address 3 bottom register sa3b read/write 0x00000000 0xac specific address 3 top register sa3t read/write 0x00000000 0xb0 specific address 4 bottom register sa4b read/write 0x00000000 0xb4 specific address 4 top register sa4t read/write 0x00000000 0xb8 type id checking register tid read/write 0x00000000 0xbc transmit pause quantum register tpq rea d/write 0x0000ffff 0xc0 user input/output register usrio read/write 0x00000000 0xc4 wake on lan register wol read/write 0x00000000 0xfc version register version read-only - (1) 1. the reset values are device specific. please refer to the module configuration section at the end of this chapter. table 24-6. macb register memory map (continued) offset register register name access reset
508 32117b?avr-03/11 at32uc3c 24.7.1 network control register name: ncr access type: read/write offset: 0x00 reset value: 0x00000000 ? tzq: transmit zero quantum pause frame writing a one to this bit sends a pause frame with zero pause quantum at the next available transmitter idle time. ? tpf: transmit pause frame writing a one to this bit sends a pause frame with the pause qua ntum from the transmit pause qu antum register at the next available transmitter idle time. ? thalt: transmit halt writing a one to this bit halts transmission as soon as any ongoing frame transmission ends. ? tstart: start transmission writing a one to this bit starts transmission. ? bp: back pressure 0: no collision are forced. 1: in half duplex mode, forces collisions on all received frames. ? westat: write enable for statistics registers 0: statistics registers are read-only. 1: statistics registers are writable for functional test purposes. ? incstat: increment statistics registers writing a one increments all the statistics registers by one for test purposes. ? clrstat: clear statistics registers writing a one clears the statistics registers. ? mpe: management port enable 0: forces mdio to high impedance state and dpc low. 1: enables the management port. ? te: transmit enable 0: transmission stops immediately, the transmit fifo and cont rol registers are cleared and the transmit queue pointer register resets to point to the start of the transmit descriptor list. 1: enables the ethernet transmitter to send data. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - tzq tpf thalt tstart bp 76543210 westat incstat clrstat mpe te re llb lb
509 32117b?avr-03/11 at32uc3c ? re: receive enable 0: frame reception stops immedi ately and the receive fifo is cleared. the re ceive queue pointer register is unaffected. 1: enables the macb to receive data. ? llb: local loopback 0: local loopback is disabled. 1: local loopback is enabled. it connects txd to rxd, tx_en to rx_dv, forces full duplex and drives rx_clk and tx_clk with clk_macb_pb divided by 4. rx_clk and tx_clk may glitch as the macb is switched into a nd out of internal loop back. it is important that receive and transmit circuits have already been disabled when making the switch into and out of internal l oop back. this function may not be supported by some instantiations of the macb. ? lb: loopback 0: loopback is disabled. 1: loopback is enabled. asserts the loopback signal to the phy.
510 32117b?avr-03/11 at32uc3c 24.7.2 network configuration register name: ncfgr access type: read/write offset: 0x04 reset value: 0x00008000 ? irxfcs: ignore rx fcs 0: normal operation. 1: frames with fcs/crc errors are not reje cted and no fcs error statistics are counted. ? efrhd: enable frames to be received in half-duplex mode 0: disabled. 1: enabled (while transmitting). ? drfcs: discard receive fcs 0: fcs field of received frames are copied to memory. 1: fcs field of received frames are not copied to memory. ? rlce: receive length field checking enable 0: disabled. 1: frames with measured lengths shorter than their length fields are discarded. fr ames containing a type id in bytes 13 and 14 (length/type id = 0600) are not be counted as length errors. ? rbof: receive buffer offset indicates the number of bytes by which the received data is offset from the start of the first receive buffer. ? pae: pause enable 0: pause disabled. 1: pause enabled. transmission pauses when a valid pause frame is received. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - irxfcs efrhd drfcs rlce 15 14 13 12 11 10 9 8 rbof pae rty clk eae fs 76543210 uni mti nbc caf jframe br fd spd rbof offset 00 no offset from start of receive buffer 01 one-byte offset from start of receive buffer 10 two-byte offset from start of receive buffer 11 three-byte offset from start of receive buffer
511 32117b?avr-03/11 at32uc3c ? rty: retry test 0: normal operation. 1: the back off between collisions is always one slot time. it hel ps testing the too many retries condition. also used in the p ause frame tests to reduce the pause counters decrement time from 512 bit times, to every rx_clk cycle. ? clk: pb clock divider determines by what number syst em clock is divided to genera te divided pb clock (dpc). for conformance with 802.3, dpc must not exceed 2.5mhz (dpc is only acti ve during mdio read and write operations). ? eae: external address match enable 0: external address match is disabled. 1: external address match is enabled. eam pin can be used to copy frames to memory. ? fs: frame size 0: reject any frames above 1518 bytes. 1: accept frames up to 1536 bytes. ? uni: unicast hash enable 0: unicast hash is disabled. 1: unicast hash is enabled. unicast frames are received when the 6-bit hash function of the destination address points to a bit that is set in the hash register. ? mti: multicast hash enable 0: multicast hash is disabled. 1: multicast hash is enabled. multicast fram es are received when the 6-bit hash function of the destination address points to a bit that is set in the hash register. ? nbc: no broadcast 0: frames addressed to the broadcast address of all ones are received. 1: frames addressed to the broadcast a ddress of all ones are not received. ? jframe: jumbo frames 0: jumbo frames are disabled. 1: enable jumbo frames of up to 10240 bytes to be accepted. ? caf: copy all frames 0: copy all frames is disabled. 1: all valid frames are received. ? br: bitrate 0: data is transmitted l east significant nibble first. 1: data is serialized and transmitted least significant bit firs t (10mbps). must be written before receive and transmit enable in the network control register. serial interface is configured with tr ansmit and receive data being driven out on txd[0] and received on rxd[0] serially. also the crs and rx_dv are logically ored together so either may be us ed as the data valid signal. ? fd: full duplex 0: full duplex mode is disabled. 1: full duplex mode is enabled. transmit sub-module ignores the state of collision and carrier sense and allows receive while transmitting. also controls the half duplex pin. ? spd: speed 0: 10 mbit/s speed. 1: 100 mbit/s speed. bit value is reflected on the speed pin. clk dpc 00 pb clock divided by 8 (pb clock up to 20 mhz) 01 pb clock divided by 16 (pb clock up to 40 mhz) 10 pb clock divided by 32 (pb clock up to 80 mhz) 11 pb clock divided by 64 (pb clock up to 160 mhz)
512 32117b?avr-03/11 at32uc3c 24.7.3 network status register name: nsr access type: read-only offset: 0x08 reset value: - ?idle: idle status 0: phy management logic is idle (i.e., has completed). 1: phy management logic is running. ? mdio: mdio pin status use the phy maintenance register for reading managed frames rather than this bit. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - idle mdio -
513 32117b?avr-03/11 at32uc3c 24.7.4 transmit status register name: tsr access type: read/write offset: 0x14 reset value: 0x00000000 this register, when read, returns details of the status of a tr ansmit. once read, individual bits may be cleared by writing a one to them. it is not possible to write a bit to one by writing to the register. ? und: transmit underrun this bit is set when transmit dma was not able to read data fr om memory, either because the bus was not granted in time or because a used bit was read midway through frame transmi ssion. if this occurs, the transmitter forces bad crc. write a one to clear this bit. 0: no transmit underrun. 1: transmit underrun. ? comp: transmit complete this bit is set when a fr ame has been transmitted. write a one to clear this bit. 0: transmit is not completed. 1: transmit is completed. ? bex: buffers exhausted mid frame this bit is set if the buffers run out during transmission of a frame. then transmission stops, fcs shall be bad and tx_er is asserted. write a one to clear to this bit. 0: buffer is not exhausted. 1: buffer is exhausted. ? tgo: transmit go 0: transmit is inactive. 1: transmit is active. ? rle: retry limit exceeded this bit is set when retry limit has exceeded. write a one to clear this bit. 0: retry limit is not exceeded. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - und comp bex tgo rle col ubr
514 32117b?avr-03/11 at32uc3c 1: retry limit is exceeded. ? col: collision occurred this bit is set by the assertion of collision. write a one to clear this bit. 0: no collision detected. 1: collision detected. ? ubr: used bit read this bit is set when a transmit buffer descriptor is read with its used bit set. write a one to clear this bit. 0: used bit is not set. 1: used bit set.
515 32117b?avr-03/11 at32uc3c 24.7.5 receive buffer queue pointer register name: rbqp access type: read/write offset: 0x18 reset value: 0x00000000 this register points to the entry in the receive buffer queue (des criptor list) currently being used. it is written with the st art location of the receive buffer descriptor list. the lower order bits increment as buffers are used up and wrap to their origina l values after either 1024 buffers or when the wrap bit of the entry is set. reading this register returns the location of the descriptor currently being accessed. this value is incremented as buffers are used. user should not use this register to determine where to remove received frames from the queue as it constantly changes when new frames are received. user should instea d use the buffer descriptor queue checking the used bits. receive buffer writes can be bursts of two words and, as with transmit buffer reads, it is recommended that bit 2 is always written to zero to prevent a burst crossing a 1k boundary, in violation of the system bus specification. ? addr: receive buffer queue pointer address write this field to set the start address of the receive queue. read this field to get the address of the current buffer being used. 31 30 29 28 27 26 25 24 addr[29:22] 23 22 21 20 19 18 17 16 addr[21:14] 15 14 13 12 11 10 9 8 addr[13:6] 76543210 addr[5:0] - -
516 32117b?avr-03/11 at32uc3c 24.7.6 transmit buffer queue pointer register name: tbqp access type: read/write offset: 0x1c reset value: 0x00000000 this register points to the entry in the transmit buffer queue (descriptor list) currently being used. it is written with the s tart location of the transmit buffer descriptor list. the lower order bits increment as buffers are used up and wrap to their origin al values after either 1024 buffers or when the wrap bit of the ent ry is set. this register can only be written when bit tsr.tgo is low. as transmit buffer reads can be bursts of two words, it is reco mmended that bit 2 is always written to zero to prevent a burst crossing a 1k boundary, in violation of the system bus specification. ? addr: transmit buffer qu eue pointer address write this field to se t the start address of the transmit queue. read this field to get the address of the first buffer of the frame being transmitted or about to be transmitted. 31 30 29 28 27 26 25 24 addr[29:22] 23 22 21 20 19 18 17 16 addr[21:14] 15 14 13 12 11 10 9 8 addr[13:6] 76543210 addr[5:0] - -
517 32117b?avr-03/11 at32uc3c 24.7.7 receive status register name: rsr access type: read/write offset: 0x20 reset value: 0x00000000 this register, when read, returns details of the status of a re ceive. once read, individual bits may be cleared by writing a one to them. it is not possible to write a bit to one by writing to the register. ? ovr: receive overrun this bit is set when the dma interface is unable to store the receive frame to memory, either because the bus was not granted i n time or because a bus error was returned. the buffer is recovered if this happens. write a one to clear this bit. 0: no receive overrun detected. 1: receive overrun detected. ? rec: frame received this bit is set when one or more frames have been received and placed in memory. write a one to clear this bit. 0: no frame received. 1: frame received. ? bna: buffer not available the dma reads the pointer each time a new frame starts, until a vali d pointer is found. this bit is set at each attempt that fa ils even if it has not had a successful pointer read since it has been cleared. write a one to clear this bit. 0: buffer is available. 1: buffer is not available because an attempt was made to get a new buffer and the pointer indicated that it was owned by the processor. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - ovr rec bna
518 32117b?avr-03/11 at32uc3c 24.7.8 interrupt status register name: isr access type: read/write offset: 0x24 reset value: 0x00000000 ? ptz: pause time zero this bit is set when the pause time register (ptr) decrements to zero. this bit is cleared after read. 0: ptr > 0. 1: ptr = 0. ? pfr: pause frame received this bit is cleared after read. 0: no valid pause frame received. 1: valid pause frame received. ? hresp: hresp not ok this bit is set when the dma interface detects a bus error. this bit is cleared after read. 0: hresp is ok. 1: hresp is not ok. ? rovr: receive overrun this bit is set when the receive overrun status bit is set (rsr.ovr). this bit is cleared after read. 0: rsr.ovr is not set. 1: rsr.ovr has been set. ? tcomp: transmit complete this bit is set when a fr ame has been transmitted. this bit is cleared after read. 0: transmit is not completed. 1: transmit is completed. ? txerr: transmit error this bit is set when transmit buffers exhausted in mid-frame. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - ptz pfr hresp rovr - - 76543210 tcomp txerr rle tund txubr rxubr rcomp mfd
519 32117b?avr-03/11 at32uc3c this bit is cleared after read. 0: no transmit error. 1: transmit error detected. ? rle: retry limit exceeded this bit is cleared after read. 0: retry limit is not exceeded. 1: retry limit is exceeded. ? tund: ethernet tran smit buffer underrun this bit is set if the dma did not fetch frame data to transmit in time or hresp returned not ok. it is also set if a used bit is read mid-frame or when a new transmit queue pointer is written. this bit is cleared after read. 0: no underrun detected for transmit buffer. 1: underrun detected for transmit buffer. ? txubr: transmit used bit read this bit is cleared after read. 0: normal operation. 1: transmit buffer descriptor is read with its used bit set. ? rxubr: receive used bit read this bit is cleared after read. 0: normal operation. 1: receive buffer descriptor is read with its used bit set. ? rcomp: receive complete this bit is set when a frame has been stored in memory. this bit is cleared after read. 0: receive is not completed. 1: receive is completed. ? mfd: management frame done this bit is cleared after read. 0: management frame is not done. 1: management frame is done. phy maintenanc e register has completed its operation.
520 32117b?avr-03/11 at32uc3c 24.7.9 interrupt enable register name: ier access type: write-only offset: 0x28 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - ptz pfr hresp rovr - - 76543210 tcomp txerr rle tund txubr rxubr rcomp mfd
521 32117b?avr-03/11 at32uc3c 24.7.10 interrupt disable register name: idr access type: write-only offset: 0x2c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - ptz pfr hresp rovr - - 76543210 tcomp txerr rle tund txubr rxubr rcomp mfd
522 32117b?avr-03/11 at32uc3c 24.7.11 interrupt mask register name: imr access type: read-only offset: 0x30 reset value: 0x00003fff 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - ptz pfr hresp rovr - - 76543210 tcomp txerr rle tund txubr rxubr rcomp mfd
523 32117b?avr-03/11 at32uc3c 24.7.12 phy maintenance register name: man access type: read/write offset: 0x34 reset value: 0x00000000 ? sof: start of frame must be written to 01 for a valid frame. ? rw: read/write 10: read operation 01: write operation. any other value is an invalid phy management frame ? phya: phy address phy address. ? rega: register address phy register address to access. ? code: code value must be written to 10. ? data: phy data for a write operation, write the data to be written to the phy. after a read operation, contai ns the data read from the phy. 31 30 29 28 27 26 25 24 sof rw phya[4:1] 23 22 21 20 19 18 17 16 phya rega code 15 14 13 12 11 10 9 8 data[15:8] 76543210 data[7:0]
524 32117b?avr-03/11 at32uc3c 24.7.13 pause time register name: ptr access type: read/write offset: 0x38 reset value: 0x00000000 ? ptime: pause time current value of the pause time register which is decremented every 512 bit times. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ptime[15:8] 76543210 ptime[7:0]
525 32117b?avr-03/11 at32uc3c 24.7.14 pause frames received register name: pfr access type: read/write offset: 0x3c reset value: 0x00000000 ? pfrok: pauses frames received ok number of good pause frames received. a good frame has a length of 64 to 1518 bytes (1536 if bit ncfgr.fs is set, 10240 if bit ncfgr.jframe is set) and has no fcs, alignment or receive symbol errors. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 pfrok[15:8] 76543210 pfrok[7:0]
526 32117b?avr-03/11 at32uc3c 24.7.15 frames transmitted ok register name: fto access type: read/write offset: 0x40 reset value: 0x00000000 ? ftok: frames transmitted ok number of frames successfully transmitted, i.e., no underrun and not too many retries. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ftok[23:16] 15 14 13 12 11 10 9 8 ftok[15:8] 76543210 ftok[7:0]
527 32117b?avr-03/11 at32uc3c 24.7.16 single collision frames register name: scf access type: read/write offset: 0x44 reset value: 0x00000000 ? scf: single collision frames number of frames experiencing a single collision before being successfully transmitted, i.e., no underrun. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 scf[15:8] 76543210 scf[7:0]
528 32117b?avr-03/11 at32uc3c 24.7.17 multicollision frames register name: mcf access type: read/write offset: 0x48 reset value: 0x00000000 ? mcf: multicollision frames number of frames experiencing between 2 and 15 collisions prio r to being successfully transmitted, i.e., no underrun and not too many retries. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 mcf[15:8] 76543210 mcf[7:0]
529 32117b?avr-03/11 at32uc3c 24.7.18 frames received ok register name: fro access type: read/write offset: 0x4c reset value: 0x00000000 ? frok: frames received ok number of frames successfully received, i.e., address recognized and successfully copied to memory. a good frame has a length of 64 to 1518 bytes (1536 if bit ncfgr.fs is set, 10240 if bit ncfgr.jframe is set) and has no fcs, alignment or receive symbol errors. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 frok[23:16] 15 14 13 12 11 10 9 8 frok[15:8] 76543210 frok[7:0]
530 32117b?avr-03/11 at32uc3c 24.7.19 frames check sequence errors register name: fcse access type: read/write offset: 0x50 reset value: 0x00000000 ? fcse: frame check sequence errors number of frames which have an integral number of bytes, have bad crc and are between 64 and 1518 bytes in length (1536 if bit ncfgr.fs is set, 10240 if bit ncfgr.jframe is set). this register is also incremented if a symbol error is detected and the frame is of valid length and has an integral number of bytes. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 fcse
531 32117b?avr-03/11 at32uc3c 24.7.20 alignment errors register name: ale access type: read/write offset: 0x54 reset value: 0x00000000 ? ale: alignment errors number of frames which have not an integral number of bytes and have bad crc when their length is truncated to an integral number of bytes and are between 64 and 1518 bytes in length (1536 if bit ncfgr.fs is set, 10240 if bit ncfgr.jframe is set). this register is also in cremented if a symbol error is detected and the fr ame is of valid length and does not have an int egral number of bytes. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ale
532 32117b?avr-03/11 at32uc3c 24.7.21 deferred transmission frames register name: dtf access type: read/write offset: 0x58 reset value: 0x00000000 ? dtf: deferred transmission frames number of frames experiencing deferral due to carrier sense being active on their first attempt at transmission. frames involve d in any collision are not counted nor are fram es that experienced a transmit underrun. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 dtf[15:8] 76543210 dtf[7:0]
533 32117b?avr-03/11 at32uc3c 24.7.22 late collisions register name: lcol access type: read/write offset: 0x5c reset value: 0x00000000 ? lcol: late collisions number of frames that experience a collision after the slot time (512 bits) has expired. a late collision is counted twice; i.e ., both as a collision and a late collision. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 lcol
534 32117b?avr-03/11 at32uc3c 24.7.23 excessive collisions register name: excol access type: read/write offset: 0x60 reset value: 0x00000000 ? excol: excessi ve collisions number of frames that failed to be transm itted because they experienced 16 collisions. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 excol
535 32117b?avr-03/11 at32uc3c 24.7.24 transmit underrun errors register name: tund access type: read/write offset: 0x64 reset value: 0x00000000 ? tund: transmit underruns number of frames not transmitted due to a transmit dma underr un. if this register is incr emented, then no ot her statistics register is incremented. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 tund
536 32117b?avr-03/11 at32uc3c 24.7.25 carrier sense errors register name: cse access type: read/write offset: 0x68 reset value: 0x00000000 ? cse: carrier sense errors number of frames transmitted where carrier sense was not s een during transmission or where carrier sense was deasserted after being asserted in a transmit frame without collision (no un derrun). only incremented in ha lf-duplex mode. the only effect of a carrier sense error is to increment this register. the beha vior of the other statistics r egisters is unaffected by the det ection of a carrier sense error. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 cse
537 32117b?avr-03/11 at32uc3c 24.7.26 received resource errors register name: rre access type: read/write offset: 0x6c reset value: 0x00000000 ? rre: received resource errors number of frames that address matched but could not be copied to memory because no receive buffer was available. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 rre[15:8] 76543210 rre[7:0]
538 32117b?avr-03/11 at32uc3c 24.7.27 received overrun errors register name: rovr access type: read/write offset: 0x70 reset value: 0x00000000 ? rovr: received overrun errors number of frames that are address recognized but were not copied to memory because of receive dma overrun. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 rovr
539 32117b?avr-03/11 at32uc3c 24.7.28 received symbol errors register name: rse access type: read/write offset: 0x74 reset value: 0x00000000 ? rse: received symbol errors number of frames that had rx_er assert ed during reception. receive symbol errors are also counted as an fcs or alignment error if the frame length is between 64 and 1518 bytes (1536 if bit ncfgr.fs is set, 10240 if bit ncfgr.jframe is set). if the frame is larger, it is recorded as a jabber error. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 rse
540 32117b?avr-03/11 at32uc3c 24.7.29 excessive length errors register name: ele access type: read/write offset: 0x78 reset value: 0x00000000 ? exl: excessive length errors number of frames received exceeding 1518 bytes (1536 if bit ncf gr.fs is set, 10240 if bit ncfgr.jframe is set) in length but do not have either a crc error, an alignment error nor a receive symbol error. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 exl
541 32117b?avr-03/11 at32uc3c 24.7.30 receive jabbers register name: rja access type: read/write offset: 0x7c reset value: 0x00000000 ? rjb: receive jabbers number of frames received exceeding 1518 bytes (1536 if bit ncf gr.fs is set, 10240 if bit ncfgr.jframe is set) in length and have either a crc error, an alignment error or a receive symbol error. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 rjb
542 32117b?avr-03/11 at32uc3c 24.7.31 undersize frames register name: usf access type: read/write offset: 0x80 reset value: 0x00000000 ? usf: undersize frames number of frames received less than 64 bytes in length but do not have either a crc error, an alignment error or a receive symbol error. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 usf
543 32117b?avr-03/11 at32uc3c 24.7.32 sqe test errors register name: ste access type: read/write offset: 0x84 reset value: 0x00000000 ? sqer: sqe test errors number of frames where col was not asserted within 96 bit ti mes (interframe gap) of tx_en being deasserted in half duplex mode. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 sqer
544 32117b?avr-03/11 at32uc3c 24.7.33 received length field mismatch register name: rle access type: read/write offset: 0x88 reset value: 0x00000000 ? rlfm: receive length field mismatch number of frames received that have a measured length shorter than extracted from its length field. checking is enabled by bit ncfgr.rlce. frames containing a type id in bytes 13 and 14 (i.e., length/type id 0x0600) are not counted as length field errors, neither are excessive length frames. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 rlfm
545 32117b?avr-03/11 at32uc3c 24.7.34 transmitted pause frames register name: tpf access type: read/write offset: 0x8c reset value: 0x00000000 ? tpf: transmitted pause frames number of pause frames transmitted. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 tpf[15:8] 76543210 tpf[7:0]
546 32117b?avr-03/11 at32uc3c 24.7.35 hash register bottom name: hrb access type: read/write offset: 0x90 reset value: 0x00000000 ? addr: hash address low low value of the hash address register. see ?hash addressing? on page 498 . 31 30 29 28 27 26 25 24 addr[31:24] 23 22 21 20 19 18 17 16 addr[23:16] 15 14 13 12 11 10 9 8 addr[15:8] 76543210 addr[7:0]
547 32117b?avr-03/11 at32uc3c 24.7.36 hash register top name: hrt access type: read/write offset: 0x94 reset value: 0x00000000 ? addr: hash address high high value of the hash address register. see ?hash addressing? on page 498 . 31 30 29 28 27 26 25 24 addr[31:24] 23 22 21 20 19 18 17 16 addr[23:16] 15 14 13 12 11 10 9 8 addr[15:8] 76543210 addr[7:0]
548 32117b?avr-03/11 at32uc3c 24.7.37 specific address 1 bottom register name: sa1b access type: read/write offset: 0x98 reset value: 0x00000000 ? addr: destination address low low value of the destination address. bit zero indicates whether the address is multicast or unicast and corresponds to the lea st significant bit of the first byte received. 31 30 29 28 27 26 25 24 addr[31:24] 23 22 21 20 19 18 17 16 addr[23:16] 15 14 13 12 11 10 9 8 addr[15:8] 76543210 addr[7:0]
549 32117b?avr-03/11 at32uc3c 24.7.38 specific address 1 top register name: sa1t access type: read/write offset: 0x9c reset value: 0x00000000 ? addr: destination address high high value of the destination address (bits 32 to 47). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 addr[15:8] 76543210 addr[7:0]
550 32117b?avr-03/11 at32uc3c 24.7.39 specific address 2 bottom register name: sa2b access type: read/write offset: 0xa0 reset value: 0x00000000 ? addr: destination address low low value of the destination address. bit zero indicates whether the address is multicast or unicast and corresponds to the lea st significant bit of the first byte received. 31 30 29 28 27 26 25 24 addr[31:24] 23 22 21 20 19 18 17 16 addr[23:16] 15 14 13 12 11 10 9 8 addr[15:8] 76543210 addr[7:0]
551 32117b?avr-03/11 at32uc3c 24.7.40 specific address 2 top register name: sa2t access type: read/write offset: 0xa4 reset value: 0x00000000 ? addr: destination address high high value of the destination address (bits 32 to 47). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 addr[15:8] 76543210 addr[7:0]
552 32117b?avr-03/11 at32uc3c 24.7.41 specific address 3 bottom register name: sa3b access type: read/write offset: 0xa8 reset value: 0x00000000 ? addr: destination address low low value of the destination address. bit zero indicates whether the address is multicast or unicast and corresponds to the lea st significant bit of the first byte received. 31 30 29 28 27 26 25 24 addr[31:24] 23 22 21 20 19 18 17 16 addr[23:16] 15 14 13 12 11 10 9 8 addr[15:8] 76543210 addr[7:0]
553 32117b?avr-03/11 at32uc3c 24.7.42 specific address 3 top register name: sa3t access type: read/write offset: 0xac reset value: 0x00000000 ? addr: destination address high high value of the destination address (bits 32 to 47). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 addr[15:8] 76543210 addr[7:0]
554 32117b?avr-03/11 at32uc3c 24.7.43 specific address 4 bottom register name: sa4b access type: read/write offset: 0xb0 reset value: 0x00000000 ? addr: destination address low low value of the destination address. bit zero indicates whether the address is multicast or unicast and corresponds to the lea st significant bit of the first byte received. 31 30 29 28 27 26 25 24 addr[31:24] 23 22 21 20 19 18 17 16 addr[23:16] 15 14 13 12 11 10 9 8 addr[15:8] 76543210 addr[7:0]
555 32117b?avr-03/11 at32uc3c 24.7.44 specific address 4 top register name: sa4t access type: read/write offset: 0xb4 reset value: 0x00000000 ? addr: destination address high high value of the destination address (bits 32 to 47). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 addr[15:8] 76543210 addr[7:0]
556 32117b?avr-03/11 at32uc3c 24.7.45 type id checking register name: tid access type: read/write offset: 0xb8 reset value: 0x00000000 ? tid: type id checking comparison value for received frames (typeid/length field). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 tid[15:8] 76543210 tid[7:0]
557 32117b?avr-03/11 at32uc3c 24.7.46 transmit pause quantum register name: tpq access type: read/write offset: 0xbc reset value: 0x0000ffff ? tpq: transmit pause quantum used in hardware generation of transmitted pause frames as value for pause quantum. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 tpq[15:8] 76543210 tpq[7:0]
558 32117b?avr-03/11 at32uc3c 24.7.47 user input/output register name: usrio access type: read/write offset: 0xc0 reset value: 0x00000000 this register, when read, returns details of the status of a re ceive. once read, individual bits may be cleared by writing a one to them. it is not possible to write a bit to one by writing to the register. ? wol: wake-on lan 0: wake-on lan not detected. 1: wake-on lan detected (read-only). ? spd: speed image of ncfgr.spd bit (read-only). ? br: bitrate image of ncfgr.br bit (read-only). ? hd: half duplex inversion of ncfgr.fd bit (read-only). ? lb: loopback image of ncr.lb bit (read-only). ? tpz: transmit pause frame zero quantum 0: pause frame is tpq register value quantum length. 1: pause frame is zero quantum length. ? tp: transmit pause frame toggle this bit to send a pause frame. ? eam: external address match 0: no frame is copied to memory. 1: frame is copied to memory if ncfgr.eae is set. ? rmii: rmii mode 0: mii operation mode. 1: rmii operation mode. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - wol spd br hd lb 15 14 13 12 11 10 9 8 -------- 76543210 ----tpztpeamrmii
559 32117b?avr-03/11 at32uc3c 24.7.48 wake-on-lan register name: wol access type: read/write offset: 0xc4 reset value: 0x0000ffff ? mti: multicast hash event enable 0: multicast hash events are disabled. 1:multicast hash events assert wol pin. ? sa1: specific address register 1 event enable 0: sar1 events are disabled. 1: sar1 events assert wol pin. ? arp: arp request event enable 0: arp request events are disabled. 1: arp request events assert wol pin. ? mag: magic packet event enable 0: magic packet events are disabled. 1: magic packet events assert wol pin. ? ip: arp request ip address 16 lsb bits of target ip. when matched, a wake-on-lan event is generated. zero value does not generate an event, even if it is matched by the received frame. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - mti sa1 arp mag 15 14 13 12 11 10 9 8 ip[15:8] 76543210 ip[7:0]
560 32117b?avr-03/11 at32uc3c 24.7.49 version register name: version access type: read-only offset: 0xfc reset value: - ? pr: part reference reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 pr[15:8] 23 22 21 20 19 18 17 16 pr[7:0] 15 14 13 12 11 10 9 8 version[15:8] 76543210 version[7:0]
561 32117b?avr-03/11 at32uc3c 24.8 module configuration the specific configuration for each macb instanc e is listed in the following tables. the module bus clocks listed here are connected to the syst em bus clocks. please refer to the power man- ager chapter for details. table 24-7. module clock name module name clock name description macb clk_macb_hsb hsb clock clk_macb_pb peripheral bus cl ock from the pbb clock domain table 24-8. register reset values module name clock name version 0x0000101d
562 32117b?avr-03/11 at32uc3c 25. universal synchronous asynchrono us receiver transmitter (usart) rev: 6.0.2.1 25.1 features ? programmable baud rate generator ? 5- to 9-bit full-duplex synchronous or asynchronous serial communications ? 1, 1.5 or 2 stop bits in asynchronous mode or 1 or 2 stop bits in synchronous mode ? parity generation and error detection ? framing error detection, overrun error detection ? msb- or lsb-first ? optional break generation and detection ? by 8 or by 16 over-sampling receiver frequency ? optional hardware handshaking rts-cts ? optional modem signal management dtr-dsr-dcd-ri ? receiver time-out and transmitter timeguard ? optional multidrop mode with address generation and detection ? rs485 with driver control signal ? iso7816, t = 0 or t = 1 protocols for interfacing with smart cards ? nack handling, error counter with repetition and iteration limit ? irda modulation and demodulation ? communication at up to 115.2 kbps ? spi mode ? master or slave ? serial clock programmable phase and polarity ? spi serial clock (clk) frequency up to internal clock frequency clk_usart/4 ? lin mode ? compliant with lin 1.3 and lin 2.0 sp ecifications ? master or slave ? processing of frames with up to 256 data bytes ? response data length can be configurable or defined automatica lly by the identifier ? self synchronization in slave node configuration ? automatic processing and verification of the ?synch break? an d the ?synch field? ? the ?synch break? is detected even if it is partially superimposed with a data byte ? automatic identifier parity ca lculation/sending and verification ? parity sending and verification can be disabled ? automatic checksum calculati on/sending and verification ? checksum sending and veri fication can be disabled ? support both ?classic? an d ?enhanced? checksum types ? full lin error checking and reporting ? frame slot mode: the master allocates sl ots to the scheduled frames automatically. ? generation of the wakeup signal ? test modes ? remote loopback, local loopback, automatic echo ? supports connection of two periph eral dma controller channels (pdca) ? offers buffer transfer without processor intervention 25.2 overview the universal synchronous asynchronous rece iver transceiver (usart) provides one full duplex universal synchronous asynchronous serial link. data frame format is widely programma-
563 32117b?avr-03/11 at32uc3c ble (data length, parity, number of stop bits) to support a maximum of standards. the receiver implements parity error, framing error and overrun error detection. the receiver time-out enables handling variable-length frames and the transmitt er timeguard facilitates communications with slow remote devices. multidrop communications are also supported through address bit han- dling in reception and transmission. the usart features three test modes: remote loopback, local loopback and automatic echo. the usart supports specific operating modes providing interfaces on rs485, lin and spi buses, with iso7816 t = 0 or t = 1 smart card slots, infrared transceivers and connection to modem ports. the hardware handshaking feature enables an out-of-band flow control by auto- matic management of the pins rts and cts. the usart supports the connection to the peripheral dma controller, which enables data transfers to the transmitter and from the receiver. the peripheral dma controller provides chained buffer management without any intervention of the processor.
564 32117b?avr-03/11 at32uc3c 25.3 block diagram figure 25-1. usart block diagram peripheral dma controller channel channel intc power manager div receiver transmitter modem signals control user interface i/o controller rxd rts txd cts dtr dsr dcd ri clk baudrate generator usart interrupt clk_usart clk_usart/div usart peripheral bus table 25-1. spi operating mode pin usart spi slave spi master rxd rxd mosi miso txd txd miso mosi rts rts ? cs cts cts cs ?
565 32117b?avr-03/11 at32uc3c 25.4 i/o lines description table 25-2. i/o lines description name description type active level clk serial clock i/o txd transmit serial data or master out slave in (mosi) in spi master mode or master in slave out (miso) in spi slave mode output rxd receive serial data or master in slave out (miso) in spi master mode or master out slave in (mosi) in spi slave mode input ri ring indicator input low dsr data set ready input low dcd data carrier detect input low dtr data terminal ready output low cts clear to send or slave select (nss) in spi slave mode input low rts request to send or slave select (nss) in spi master mode output low
566 32117b?avr-03/11 at32uc3c 25.5 product dependencies 25.5.1 i/o lines the pins used for interfacing the usart may be multiplexed with the i/o controller lines. the programmer must first program the i/o controller to assign the desired usart pins to their peripheral function. if i/o lines of the usart are not used by the application, they can be used for other purposes by the i/o controller. to prevent the txd line from falling when the usart is di sabled, the use of an internal pull up is mandatory. if the hardware handshaking feature or modem mode is used, the internal pull up on txd must also be enabled. all the pins of the modems may or may not be implemented on the usart. on usarts not equipped with the corresponding pins, the associat ed control bits and statuses have no effect on the behavior of the usart. 25.5.2 clocks the clock for the usart bus interface (clk_usart) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to dis- able the usart before disabling the clock, to avoid freezing the usart in an undefined state. 25.5.3 interrupts the usart interrupt request line is connected to the interrupt controller. using the usart interrupt requires the interrupt controller to be programmed first.
567 32117b?avr-03/11 at32uc3c 25.6 functional description the usart is capable of managing several ty pes of serial synchronous or asynchronous communications. it supports the following communication modes: ? 5- to 9-bit full-duplex asynchronous serial communication ? msb- or lsb-first ? 1, 1.5 or 2 stop bits ? parity even, odd, marked, space or none ? by 8 or by 16 over-sampling receiver frequency ? optional hardware handshaking ? optional modem signals management ? optional break management ? optional multidrop serial communication ? high-speed 5- to 9-bit full-duplex synchronous serial communication ? msb- or lsb-first ? 1 or 2 stop bits ? parity even, odd, marked, space or none ? by 8 or by 16 over-sampling frequency ? optional hardware handshaking ? optional modem signals management ? optional break management ? optional multidrop serial communication ? rs485 with driver control signal ? iso7816, t0 or t1 protocols for interfacing with smart cards ? nack handling, error counter with repetition and iteration limit, inverted data ? infrared irda modulation and demodulation ? spi mode ?master or slave ? serial clock programmable phase and polarity ? spi serial clock (clk) frequency up to internal clock frequency clk_usart/4 ? lin mode ? compliant with lin 1.3 a nd lin 2.0 specifications ?master or slave ? processing of frames with up to 256 data bytes ? response data length can be configurable or defined automatically by the identifier ? self synchronization in slave node configuration ? automatic processing and verification of the ?synch break? and the ?synch field? ? the ?synch break? is detected even if it is partially superimposed with a data byte ? automatic identifier parity calculation/sending and verification ? parity sending and verification can be disabled ? automatic checksum calculation/sending and verification ? checksum sending and verification can be disabled ? support both ?classic? and ?enhanced? checksum types
568 32117b?avr-03/11 at32uc3c ? full lin error checking and reporting ? frame slot mode: the master allocates slots to the scheduled frames automatically. ? generation of the wakeup signal ? test modes ? remote loopback, local loopback, automatic echo 25.6.1 baud rate generator the baud rate generator provides the bit period clock named the baud rate clock to both the receiver and the transmitter. the baud rate generator clock source can be selected by setting the usclks field in the mode register (mr) between: ? clk_usart ? a division of clk_usart, the divider being product dependent, but generally set to 8 ? the external clock, available on the clk pin the baud rate generator is based upon a 16-bit divider, which is programmed with the cd field of the baud rate generator register (brgr). if cd is programmed at 0, the baud rate gener- ator does not generate any clock. if cd is programmed at 1, the divider is bypassed and becomes inactive. if the external clk clock is selected, the duration of the low and high levels of the signal pro- vided on the clk pin must be longer than a clk_usart period. the frequency of the signal provided on clk must be at least 4.5 times lower than clk_usart. figure 25-2. baud rate generator 25.6.1.1 baud rate in asynchronous mode if the usart is programmed to operate in as ynchronous mode, the selected clock is first divided by cd, which is field programmed in the baud rate generator register (brgr). the resulting clock is provided to the receiver as a sampling clock and then divided by 16 or 8, depending on the programming of the over bit in mr. if over is set to 1, the receiver sampling is 8 times higher than the baud rate clock. if over is cleared, the sampling is performed at 16 times the baud rate clock. 16-bit counter cd usclks cd clk_usart clk_usart/div reserved clk sync sync usclks= 3 fidi over sampling divider baudrate clock sampling clock 1 0 0 clk 0 1 2 3 >1 1 1 0 0
569 32117b?avr-03/11 at32uc3c the following formula performs the calculation of the baud rate. this gives a maximum baud rate of clk_usar t divided by 8, assuming that clk_usart is the highest possible clock and that over is programmed at 1. 25.6.1.2 baud rate calculation example table 25-3 shows calculations of cd to obtain a baud rate at 38400 bauds for different source clock frequencies. this table also shows the actual resulting baud rate and the error. the baud rate is calculated with the following formula: the baud rate error is calculated with the following formula. it is not recommended to work with an error higher than 5%. baudrate selectedclock 82 over ? () cd () -------------------------------------------- = table 25-3. baud rate example (over = 0) source clock expected baud rate calculation result cd actual baud rate error mhz bit/s bit/s 3 686 400 38 400 6.00 6 38 400.00 0.00% 4 915 200 38 400 8.00 8 38 400.00 0.00% 5 000 000 38 400 8.14 8 39 062.50 1.70% 7 372 800 38 400 12.00 12 38 400.00 0.00% 8 000 000 38 400 13.02 13 38 461.54 0.16% 12 000 000 38 400 19.53 20 37 500.00 2.40% 12 288 000 38 400 20.00 20 38 400.00 0.00% 14 318 180 38 400 23.30 23 38 908.10 1.31% 14 745 600 38 400 24.00 24 38 400.00 0.00% 18 432 000 38 400 30.00 30 38 400.00 0.00% 24 000 000 38 400 39.06 39 38 461.54 0.16% 24 576 000 38 400 40.00 40 38 400.00 0.00% 25 000 000 38 400 40.69 40 38 109.76 0.76% 32 000 000 38 400 52.08 52 38 461.54 0.16% 32 768 000 38 400 53.33 53 38 641.51 0.63% 33 000 000 38 400 53.71 54 38 194.44 0.54% 40 000 000 38 400 65.10 65 38 461.54 0.16% 50 000 000 38 400 81.38 81 38 580.25 0.47% 60 000 000 38 400 97.66 98 38 265.31 0.35% baudrate clkusart () cd 16 () ? =
570 32117b?avr-03/11 at32uc3c 25.6.1.3 fractional baud rate in asynchronous mode the baud rate generator previously defined is su bject to the following limitation: the output fre- quency changes by only integer multiples of the reference frequency. an approach to this problem is to integrate a fractional n clock generator that has a high resolution. the generator architecture is modified to obtain baud rate c hanges by a fraction of the reference source clock. this fractional part is programmed with the fp field in the baud rate generator register (brgr). if fp is not 0, the fractional part is acti vated. the resolution is one eighth of the clock divider. this feature is only available when using usart normal mode. the fractional baud rate is calculated using the following formula: the modified architecture is presented below: figure 25-3. fractional baud rate generator 25.6.1.4 baud rate in synchronous mode or spi mode if the usart is programmed to operate in synchronous mode, the selected clock is simply divided by the field cd in brgr. error 1 expectedbaudrate actualbaudrate -------------------------------------------------- - ?? ?? ? = baudrate selectedclock 82 over ? () cd fp 8 ------- + ?? ?? ?? ?? ---------------------------------------------------------------- - = usclks cd modulus control fp fp cd glitch-free logic 16-bit counter over fidi sync sampling divider clk_usart clk_usart/div reserved clk clk baudrate clock sampling clock sync usclks = 3 >1 1 2 3 0 0 1 0 1 1 0 0 baudrate selectedclock cd ------------------------------------- - =
571 32117b?avr-03/11 at32uc3c in synchronous mode, if the external clock is selected (usclks = 3), the clock is provided directly by the signal on the usart clk pin. no division is active. the value written in brgr has no effect. the external clock frequency must be at least 4.5 times lower than the system clock. when either the external clock clk or the inte rnal clock divided (clk_usart/div) is selected, the value programmed in cd must be even if the user has to ensure a 50:50 mark/space ratio on the clk pin. if the internal clock clk_usart is selected, the baud rate generator ensures a 50:50 duty cycle on the clk pin, even if the value programmed in cd is odd. 25.6.1.5 baud rate in iso 7816 mode the iso7816 specification defines the bit rate with the following formula: where: ? b is the bit rate ? di is the bit-rate adjustment factor ? fi is the clock frequency division factor ? f is the iso7816 clock frequency (hz) di is a binary value encoded on a 4-bit field, named di, as represented in table 25-4 . fi is a binary value encoded on a 4-bi t field, named fi, as represented in table 25-5 . table 25-6 shows the resulting fi/di ratio, which is the ratio between the iso7816 clock and the baud rate clock. if the usart is configured in iso7816 mode, th e clock selected by the usclks field in the mode register (mr) is first divided by the valu e programmed in the field cd in the baud rate b di fi ----- - f = table 25-4. binary and decimal values for di di field 0001 0010 0011 0100 0101 0110 1000 1001 di (decimal)1 2 4 8 163212 20 table 25-5. binary and decimal values for fi fi field 0000 0001 0010 0011 0100 0101 0110 1001 1010 1011 1100 1101 fi (decimal 372 372 558 744 1116 1488 1860 512 768 1024 1536 2048 table 25-6. possible values for the fi/di ratio fi/di 372 558 774 1116 1488 1806 512 768 1024 1536 2048 1 372 558 744 1116 1488 1860 512 768 1024 1536 2048 2 186 279 372 558 744 930 256 384 512 768 1024 4 93 139.5 186 279 372 465 128 192 256 384 512 8 46.5 69.75 93 139.5 186 232.5 64 96 128 192 256 16 23.25 34.87 46.5 69.75 93 116.2 32 48 64 96 128 32 11.62 17.43 23.25 34.87 46.5 58.13 16 24 32 48 64 12 31 46.5 62 93 124 155 42.66 64 85.33 128 170.6 20 18.6 27.9 37.2 55.8 74.4 93 25.6 38.4 51.2 76.8 102.4
572 32117b?avr-03/11 at32uc3c generator register (brgr). the resulting clock can be provided to the clk pin to feed the smart card clock inputs. this means that the clko bit can be set in mr. this clock is then divided by the value progra mmed in the fi_di_ratio field in the fi_di_ratio register (fidi). this is performed by the sampling divider, which performs a division by up to 2047 in iso7816 mode. the non-integer values of the fi/di ratio are not supported and the user must program the fi_di_ratio field to a value as close as possible to the expected value. the fi_di_ratio field resets to the value 0x174 (372 in decimal) and is the most common divider between the iso7816 clock and the bit rate (fi = 372, di = 1). figure 25-4 shows the relation between the elementary time unit, corresponding to a bit time, and the iso 7816 clock. figure 25-4. elementary time unit (etu) 25.6.2 receiver and transmitter control after reset, the receiver is disabled. the user must enable the receiver by setting the rxen bit in the control register (cr). however, the receiver registers can be programmed before the receiver clock is enabled. after reset, the transmitter is disabled. the user must enable it by setting the txen bit in the control register (cr). however, the transmitter registers can be programmed before being enabled. the receiver and the transmitter can be enabled together or independently. at any time, the software can perform a reset on the receiver or the transmitter of the usart by setting the corresponding bit, rstrx and rsttx re spectively, in the control register (cr). the software resets clear the status flag and rese t internal state machines but the user interface configuration registers hold the value configured prior to software reset. regardless of what the receiver or the transmitter is performing, the communication is immediately stopped. the user can also independently disable the receiv er or the transmitter by setting rxdis and txdis respectively in cr. if the receiver is disabled during a character reception, the usart waits until the end of reception of the current character, then the reception is stopped. if the transmitter is disabled while it is operating, the usart waits the end of transmission of both the current character and character being stored in the transmit holding register (thr). if a time- guard is programmed, it is handled normally. 1 etu fi_di_ratio iso7816 clock cycles iso7816 clock on clk iso7816 i/o line on txd
573 32117b?avr-03/11 at32uc3c 25.6.3 synchronous and asynchronous modes 25.6.3.1 transmitter operations the transmitter performs the same in both synchronous and asynchronous operating modes (sync = 0 or sync = 1). one start bit, up to 9 da ta bits, one optional parity bit and up to two stop bits are successively shifted out on the txd pin at each falling edge of the programmed serial clock. the number of data bits is selected by the chrl field and the mode 9 bit in the mode register (mr). nine bits are selected by setting the mode 9 bit regardless of the chrl field. the parity bit is set according to the par field in mr. the even, odd, space, marked or none parity bit can be configured. the msbf field in mr configures wh ich data bit is sent first. if written at 1, the most significant bit is sent first. at 0, the less signi ficant bit is sent first. the number of stop bits is selected by the nbstop field in mr. the 1.5 stop bit is supported in asynchronous mode only. figure 25-5. character transmit the characters are sent by writing in the tr ansmit holding register (thr). the transmitter reports two status bits in the channel status register (csr): txrdy (transmitter ready), which indicates that thr is empt y and txempty, which indicates that all the characters written in thr have been processed. when the current character processing is completed, the last character written in thr is transferred into the shift register of the transmitter and thr becomes empty, thus txrdy rises. both txrdy and txempty bits are low when the transmitter is disabled. writing a character in thr while txrdy is low has no effect and the written character is lost. figure 25-6. transmitter status d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit example: 8-bit, parity enabled one stop baud rate clock d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock start bit write thr d0 d1 d2 d3 d4 d5 d6 d7 parity bit stop bit txrdy txempty
574 32117b?avr-03/11 at32uc3c 25.6.3.2 manchester encoder when the manchester encoder is in use, c haracters transmitted through the usart are encoded based on biphase manchester ii format. to enable this mode, set the man field in the mr register to 1. depending on polarity configurat ion, a logic level (zero or one), is transmitted as a coded signal one-to-zero or zero-to-one. thus, a transition always occurs at the midpoint of each bit time. it consumes more bandwidth than the original nrz signal (2x) but the receiver has more error control since the expected input must show a change at the center of a bit cell. an example of manchester encoded sequence is: th e byte 0xb1 or 10110001 encodes to 10 01 10 10 01 01 01 10, assuming the default polarity of the encoder. figure 25-7 illustrates this coding scheme. figure 25-7. nrz to manchester encoding the manchester encoded character can also be enc apsulated by adding both a configurable preamble and a start frame delimiter pattern. depending on the configuration, the preamble is a training sequence, composed of a pre-defined pattern with a programmable length from 1 to 15 bit times. if the preamble length is set to 0, the preamble waveform is not generated prior to any character. the preamble pattern is chosen among the following sequences: all_one, all_zero, one_zero or zero_one, writing the field tx_pp in the man register, the field tx_pl is used to configure the preamble length. figure 25-8 illustrates and defines the valid patterns. to improve flexibility, the encodi ng scheme can be configured using the tx_mpol field in the man register. if the tx_mpol field is set to zero (default), a logic zero is encoded with a zero-to-one transition and a logic one is encoded with a one-to-zero transition. if the tx_mpol field is set to one, a logic one is encoded with a one-to-zero transition and a logic zero is encoded with a zero-to-one transition. nrz encoded data manchester encoded data 10110001 txd
575 32117b?avr-03/11 at32uc3c figure 25-8. preamble patterns, default polarity assumed a start frame delimiter is to be configured using the onebit field in the mr register. it consists of a user-defined pattern that indicates the beginning of a valid data. figure 25-9 illustrates these patterns. if the start frame delimiter, also known as start bit, is one bit, (onebit at 1), a logic zero is manchester encoded and indicates that a new character is being sent serially on the line. if the start frame delimiter is a synchronization pattern also referred to as sync (onebit at 0), a sequence of 3 bit times is sent serially on the line to indicate the start of a new character. the sync waveform is in itself an invalid manchester waveform as the transition occurs at the middle of the second bit time. two distinct sync patterns are used: the command sync and the data sync. the command sync has a logic one level for one and a half bit times, then a transition to logic zero for the second one and a half bit times. if the modsync field in the mr register is set to 1, the next character is a command. if it is set to 0, the next character is a data. when direct memory access is used, the modsync field can be immediately updated with a modified character located in memory. to enable this mode, var_sync field in mr register must be set to 1. in this case, the modsync field in mr is bypassed and the sync configuration is held in the txsynh in the thr register. the usart character format is modified and includes sync information. manchester encoded data txd sfd data 8 bit width "all_one" preamble manchester encoded data txd sfd data 8 bit width "all_zero" preamble manchester encoded data txd sfd data 8 bit width "zero_one" preamble manchester encoded data txd sfd data 8 bit width "one_zero" preamble
576 32117b?avr-03/11 at32uc3c figure 25-9. start frame delimiter drift compensation drift compensation is available only in 16x oversampling mode. an ha rdware recovery system allows a larger clock drift. to enable the hardwa re system, the bit in th e man register must be set. if the rxd edge is one 16x clock cycle from the expected edge, this is considered as nor- mal jitter and no corrective actions is taken. if the rxd event is between 4 and 2 clock cycles before the expected edge, then the current period is shortened by one clock cycle. if the rxd event is between 2 and 3 clock cycles after the expected edge, then the current period is length- ened by one clock cycle. these intervals are considered to be drift and so corrective actions are automatically taken. figure 25-10. bit resynchronization 25.6.3.3 asynchronous receiver if the usart is programmed in asynchronous operating mode (sync = 0), the receiver over- samples the rxd input line. the oversampling is either 16 or 8 times the baud rate clock, depending on the over bit in the mode register (mr). manchester encoded data txd sfd data one bit start frame delimiter preamble length is set to 0 manchester encoded data txd sfd data command sync start frame delimiter manchester encoded data txd sfd data data sync start frame delimiter rxd oversampling 16x clock sampling point expected edge tolerance synchro. jump sync jump synchro. error synchro. error
577 32117b?avr-03/11 at32uc3c the receiver samples the rxd line. if the line is sampled during one half of a bit time at 0, a start bit is detected and data, parity and stop bits are successively sampled on the bit rate clock. if the oversampling is 16, (over at 0), a start is detected at the eighth sample at 0. then, data bits, parity bit and stop bit are sampled on each 16 sampling clock cycle. if the oversampling is 8 (over at 1), a start bit is detected at the fourth sample at 0. then, data bits, parity bit and stop bit are sampled on each 8 sampling clock cycle. the number of data bits, first bit sent and parity mode are selected by the same fields and bits as the transmitter, i.e. respectively chrl , mode9, msbf and par. for the synchronization mechanism only , the number of stop bits has no effect on the receiver as it considers only one stop bit, regardless of the field nbstop, so that resynchronization between the receiver and the transmitter can occur. moreover, as soon as the st op bit is sampled, the receiver starts looking for a new start bit so that resynchronization can also be accomplished when the transmitter is operating with one stop bit. figure 25-11 and figure 25-12 illustrate start detection and character reception when usart operates in asynchronous mode. figure 25-11. asynchronous start detection figure 25-12. asynchronous character reception sampling clock (x16) rxd start detection sampling baud rate clock rxd start rejection sampling 12345678 12345670 1234 12345678 9 10111213141516 d0 sampling d0 d1 d2 d3 d4 d5 d6 d7 rxd parity bit stop bit example: 8-bit, parity enabled baud rate clock start detection 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples
578 32117b?avr-03/11 at32uc3c 25.6.3.4 manchester decoder when the man field in mr register is set to 1, the manchester decoder is enabled. the decoder performs both preamble and start frame delimiter detection. one input line is dedicated to man- chester encoded input data. an optional preamble sequence can be defined, it s length is user-defined and totally indepen- dent of the emitter side. use rx_pl in man regi ster to configure the length of the preamble sequence. if the length is set to 0, no preamble is detected and the function is disabled. in addi- tion, the polarity of the input stream is programmable with rx_mpol field in man register. depending on the desired application the preamble pattern matching is to be defined via the rx_pp field in man. see figure 25-8 for available preamble patterns. unlike preamble, the start frame delimiter is shared between manchester encoder and decoder. so, if onebit field is set to 1, only a zero encoded manchester can be detected as a valid start frame delimiter. if onebit is set to 0, only a sync pattern is detected as a valid start frame delimiter. decoder operates by detecting transition on incoming stream. if rxd is sampled dur- ing one quarter of a bit time at zero, a start bit is detected. see figure 25-13 . the sample pulse rejection mechanism applies. figure 25-13. asynchronous star t bit detection the receiver is activated and starts preamble and frame delimiter detection, sampling the data at one quarter and then three quarters. if a valid preamble pattern or start frame delimiter is detected, the receiver continues decoding with the same synchronization. if the stream does not match a valid pattern or a valid start frame delimiter, the receiver re-synchronizes on the next valid edge.the minimum time threshold to estimate the bit value is three quarters of a bit time. if a valid preamble (if used) followed with a valid start frame delimiter is detected, the incoming stream is decoded into nrz data and passed to usart for processing. figure 25-14 illustrates manchester pattern mismatch. when incoming data stream is passed to the usart, the receiver is also able to detect manchester code vi olation. a code violation is a lack of transition in the middle of a bit cell. in this case, mane flag in csr register is raised. it is cleared by writing the control register (cr) with the rststa bit at 1. see figure 25-15 for an example of man- chester error detection during data phase. manchester encoded data txd 1234 sampling clock (16 x) start detection
579 32117b?avr-03/11 at32uc3c figure 25-14. preamble pattern mismatch figure 25-15. manchester error flag when the start frame delimiter is a sync pattern (onebit field at 0), both command and data delimiter are supported. if a valid sync is detec ted, the received character is written as rxchr field in the rhr register and the rxsynh is updated. rxchr is set to 1 when the received character is a command, and it is set to 0 if the received character is a data. this mechanism alleviates and simplifies the direct memory access as the character contains its own sync field in the same register. as the decoder is setup to be used in unipolar mode, the first bit of the frame has to be a zero-to- one transition. 25.6.3.5 radio interface: manchester encoded usart application this section describes low data rate rf transm ission systems and their integration with a man- chester encoded usart. these systems are based on transmitter and receiver ics that support ask and fsk modulation schemes. the goal is to perform full duplex radio transmissi on of characters using two different frequency carriers. see the configuration in figure 25-16 . manchester encoded data txd sfd data preamble length is set to 8 preamble mismatch invalid pattern preamble mismatch manchester coding error manchester encoded data txd sfd preamble length is set to 4 elementary character bit time manchester coding error detected sampling points preamble subpacket and start frame delimiter were successfully decoded entering usart character area
580 32117b?avr-03/11 at32uc3c figure 25-16. manchester encoded characters rf transmission the usart module is configured as a manchester encoder/decoder. looking at the down- stream communication channel, manchester encoded characters are serially sent to the rf emitter. this may also include a user defined preamble and a start frame delimiter. mostly, pre- amble is used in the rf receiver to distinguish between a valid data from a transmitter and signals due to noise. the manchester stream is then modulated. see figure 25-17 for an exam- ple of ask modulation scheme. when a logic one is sent to the ask modulator, the power amplifier, referred to as pa, is enabled and transmits an rf signal at downstream frequency. when a logic zero is transmitted, the rf signal is turned off. if the fsk modulator is activated, two different frequencies are used to transmit dat a. when a logic 1 is sent, the modulator out- puts an rf signal at frequency f0 and switches to f1 if the data sent is a 0. see figure 25-18 . from the receiver side, another carrier frequency is used. the rf receiver performs a bit check operation examining demodulated data stream. if a valid pattern is detected, the receiver switches to receiving mode. the demodulated stream is sent to the manchester decoder. because of bit checking inside rf ic, the data transferred to the microcontroller is reduced by a user-defined number of bits. the manchester preamble length is to be defined in accordance with the rf ic configuration. figure 25-17. ask modulator output lna vco rf filter demod control bi-dir line pa rf filter mod vco control manchester decoder manchester encoder usart receiver usart emitter ask/fsk upstream receiver ask/fsk downstream transmitter upstream emitter downstream receiver serial configuration interface fup frequency carrier fdown frequency carrier manchester encoded data default polarity unipolar output txd ask modulator output uptstream frequency f0 nrz stream 10 0 1
581 32117b?avr-03/11 at32uc3c figure 25-18. fsk modulator output 25.6.3.6 synchronous receiver in synchronous mode (sync = 1), the receiver samples the rxd signal on each rising edge of the baud rate clock. if a lo w level is detected, it is considered as a start. all data bits, the parity bit and the stop bits are sampled and the receiver waits for the next start bit. synchronous mode operations provide a high speed transfer capability. configuration fields and bits are the same as in asynchronous mode. figure 25-19 illustrates a character rec eption in synchronous mode. figure 25-19. synchronous mode character reception 25.6.3.7 receiver operations when a character reception is completed, it is transferred to the receive holding register (rhr) and the rxrdy bit in the st atus register (csr) rises. if a character is completed while the rxrdy is set, the ovre (overrun error) bit is set. the last character is transferred into rhr and overwrites the previous one. the ovre bit is cleared by writing the control register (cr) with the rststa (reset status) bit at 1. manchester encoded data default polarity unipolar output txd fsk modulator output uptstream frequencies [f0, f0+offset] nrz stream 10 0 1 d0 d1 d2 d3 d4 d5 d6 d7 rxd start sampling parity bit stop bit example: 8-bit, parity enabled 1 stop baud rate clock
582 32117b?avr-03/11 at32uc3c figure 25-20. receiver status d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit parity bit stop bit baud rate clock write cr rxrdy ovre d0 d1 d2 d3 d4 d5 d6 d7 start bit parity bit stop bit rststa = 1 read rhr
583 32117b?avr-03/11 at32uc3c 25.6.3.8 parity the usart supports five parity modes selected by programming the par field in the mode register (mr). the par field also enables the multidrop mode, see ?multidrop mode? on page 584 . even and odd parity bit generation and error detection are supported. if even parity is selected, the parity generator of the transmitter drives the parity bit at 0 if a num- ber of 1s in the character data bit is even, and at 1 if the number of 1s is odd. accordingly, the receiver parity checker counts the number of received 1s and reports a parity error if the sam- pled parity bit does not correspond. if odd parity is selected, the parity generator of the transmitter drives the parity bit at 1 if a number of 1s in the character data bit is even, and at 0 if the number of 1s is odd. accordingly, the receiver parity checker counts the number of received 1s and reports a parity error if the sampled parity bit does not correspond. if the mark parity is used, the parity generator of the transmitter drives the parity bit at 1 for all characters. the receiver parity checker reports an error if the parity bit is sampled at 0. if the space parity is used, the parity generator of the transmitter drives the parity bit at 0 for all characters. the receiver parity checker reports an error if the parity bit is sampled at 1. if parity is disabled, the transmitter does not generate any parity bit and the receiver does not report any parity error. table 25-7 shows an example of the parity bit for the character 0x41 (character ascii ?a?) depending on the configuration of the usart. because there are two bits at 1, 1 bit is added when a parity is odd, or 0 is added when a parity is even. when the receiver detects a parity error, it sets the pare (parity error) bit in the channel status register (csr). the pare bit can be cleared by writing the control register (cr) with the rst- sta bit at 1. figure 25-21 illustrates the parity bit status setting and clearing. table 25-7. parity bit examples character hexa binary parity bit parity mode a 0x41 0100 0001 1 odd a 0x41 0100 0001 0 even a 0x41 0100 0001 1 mark a 0x41 0100 0001 0 space a 0x41 0100 0001 none none
584 32117b?avr-03/11 at32uc3c figure 25-21. parity error 25.6.3.9 multidrop mode if the par field in the mode register (mr) is programmed to the value 0x6 or 0x07, the usart runs in multidrop mode. this mode differentia tes the data characters and the address charac- ters. data is transmitted with the parity bit at 0 and addresses are transmitted with the parity bit at 1. if the usart is configured in multidrop mode, the receiver sets the pare parity error bit when the parity bit is high and the transmitter is able to send a character with the parity bit high when the control register is written with the senda bit at 1. to handle parity error, the pare bit is cleared when the control register is written with the bit rststa at 1. the transmitter sends an address byte (parity bit set) when senda is written to cr. in this case, the next byte written to thr is transmitted as an address. any character written in thr without having written the command senda is transmitted normally with the parity at 0. 25.6.3.10 transmitter timeguard the timeguard feature enables the usar t interface with slow remote devices. the timeguard function enables the transmitter to insert an idle state on the txd line between two characters. this idle state actually acts as a long stop bit. the duration of the idle state is programmed in the tg field of the transmitter timeguard regis- ter (ttgr). when this field is programmed at zero no timeguard is generated. otherwise, the transmitter holds a high level on txd after each transmitted byte during the number of bit peri- ods programmed in tg in addition to the number of stop bits. as illustrated in figure 25-22 , the behavior of txrdy and txempty status bits is modified by the programming of a timeguard. txrdy rises only when the start bit of the next character is sent, and thus remains at 0 during the timeguard transmission if a character has been written in thr. txempty remains low until the timeguard transmission is completed as the timeguard is part of the current character being transmitted. d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit bad parity bit stop bit baud rate clock write cr pare rxrdy rststa = 1
585 32117b?avr-03/11 at32uc3c figure 25-22. timeguard operations table 25-8 indicates the maximum length of a timeguard period that the transmitter can handle in relation to the function of the baud rate. 25.6.3.11 receiver time-out the receiver time-out provides support in handling variable-length frames. this feature detects an idle condition on the rxd line. when a time-out is detected, the bit timeout in the channel status register (csr) rises and can generate an interrupt, thus indicating to the driver an end of frame. the time-out delay period (during which the receiver waits for a new character) is programmed in the to field of the receiver time-out register (rtor). if the to field is programmed at 0, the receiver time-out is disabled and no time-out is detected. the timeou t bit in csr remains at 0. otherwise, the receiver loads a counter with the value programmed in to. this counter is decremented at each bit period and reloaded each time a new character is received. if the coun- ter reaches 0, the timeout bit in the status register rises. then, the user can either: ? stop the counter clock until a new character is received. this is performed by writing the control register (cr) with the sttto (start time-out) bit at 1. in this case, the idle state on rxd before a new character is received will not provide a time-out. this prevents having to d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit b aud rate clock start bit tg = 4 write thr d0 d1 d2 d3 d4 d5 d6 d7 parity bit stop bit txrdy t xempty tg = 4 table 25-8. maximum timeguard length depending on baud rate baud rate bit time timeguard bit/sec s ms 1 200 833 212.50 9 600 104 26.56 14400 69.4 17.71 19200 52.1 13.28 28800 34.7 8.85 33400 29.9 7.63 56000 17.9 4.55 57600 17.4 4.43 115200 8.7 2.21
586 32117b?avr-03/11 at32uc3c handle an interrupt before a character is received and allows waiting for the next idle state on rxd after a fram e is received. ? obtain an interrupt while no character is receiv ed. this is performed by writing cr with the retto (reload and start time-out) bit at 1. if retto is performed, the counter starts counting down immediately from the value to. this enables generation of a periodic interrupt so that a user time-out can be handled, for example when no key is pressed on a keyboard. if sttto is performed, the counter clock is stopped until a first character is received. the idle state on rxd before the start of the frame does not provide a time-out. this prevents having to obtain a periodic interrupt and enables a wait of the end of frame when the idle state on rxd is detected. if retto is performed, the counter starts counting down immediately from the value to. this enables generation of a periodic interrupt so t hat a user time-out can be handled, for example when no key is pressed on a keyboard. figure 25-23 shows the block diagram of the receiver time-out feature. figure 25-23. receiver time-o ut block diagram table 25-9 gives the maximum time-out period for some standard baud rates. table 25-9. maximum time-out period baud rate bit time time-out bit/sec s ms 600 1 667 109 225 1 200 833 54 613 2 400 417 27 306 4 800 208 13 653 9 600 104 6 827 14400 69 4 551 19200 52 3 413 28800 35 2 276 33400 30 1 962 16-bit time-out counter 0 to timeout baud rate clock = character received retto load clock 16-bit value sttto dq 1 clear
587 32117b?avr-03/11 at32uc3c 25.6.3.12 framing error the receiver is capable of detecting framing errors. a framing error happens when the stop bit of a received character is detected at level 0. this can occur if the receiver and the transmitter are fully desynchronized. a framing error is reported on the frame bit of the channel status register (csr). the frame bit is asserted in the middle of the stop bit as soon as the framing error is detected. it is cleared by writing the control register (cr) with the rststa bit at 1. figure 25-24. framing error status 25.6.3.13 transmit break the user can request the transmitter to generate a break condition on the txd line. a break con- dition drives the txd line low during at least one complete character. it appears the same as a 0x00 character sent with the parity and the stop bits at 0. however, the transmitter holds the txd line at least during one character until the user requests the break condition to be removed. a break is transmitted by writing the control register (cr) with the sttbrk bit at 1. this can be performed at any time, either while the transmitter is empty (no character in either the shift reg- ister or in thr) or when a character is being transmitted. if a break is requested while a character is being shifted out, t he character is first completed be fore the txd line is held low. once sttbrk command is requested further sttbrk commands are ignored until the end of the break is completed. the break condition is removed by writing cr with the stpbrk bit at 1. if the stpbrk is requested before the end of the minimum break duration (one character, including start, data, parity and stop bits), the transmitter ensures that the break condition completes. 56000 18 1 170 57600 17 1 138 200000 5 328 table 25-9. maximum time-out period (continued) baud rate bit time time-out d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit parity bit stop bit baud rate clock write cr frame rxrdy rststa = 1
588 32117b?avr-03/11 at32uc3c the transmitter considers the break as though it is a character, i.e. the sttbrk and stpbrk commands are taken into account only if the txrdy bit in csr is at 1 and the start of the break condition clears the txrdy and txempty bits as if a character is processed. writing cr with the both sttbrk and stpbrk bits at 1 can lead to an unpredictable result. all stpbrk commands requested without a previous sttbrk command are ignored. a byte writ- ten into the transmit holding re gister while a break is pending, but not started, is ignored. after the break condition, the transmitter returns the txd line to 1 for a minimum of 12 bit times. thus, the transmitter ensures that the remote receiver detects correctly the end of break and the start of the next character. if the timeguard is programmed with a value higher than 12, the txd line is held high for the timeguard period. after holding the txd line for this period, the transmitter resumes normal operations. figure 25-25 illustrates the effect of both the start break (sttbrk ) and stop break (stpbrk) commands on the txd line. figure 25-25. break transmission 25.6.3.14 receive break the receiver detects a break condition when all data, parity and stop bits are low. this corre- sponds to detecting a framing error with data at 0x00, but frame remains low. when the low stop bit is detected, the receiver asserts the rxbrk bit in csr. this bit may be cleared by writing the control register (cr) with the bit rststa at 1. an end of receive break is detected by a high leve l for at least 2/16 of a bit period in asynchro- nous operating mode or one sample at high level in synchronous operating mode. the end of break detection also asserts the rxbrk bit. 25.6.3.15 hardware handshaking the usart features a hardware handshaking out-of-band flow control. the rts and cts pins are used to connect with the remote device, as shown in figure 25-26 . d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock write cr txrdy txempty stpbrk = 1 sttbrk = 1 break transmission end of break
589 32117b?avr-03/11 at32uc3c figure 25-26. connection with a remote device for hardware handshaking setting the usart to operate with hardware handshaking is performed by writing the mode field in the mode register (mr) to the value 0x2. the usart behavior when hardware handshaking is enabled is the same as the behavior in standard synchronous or asynchronous mode, except that the receiver drives the rts pin as described below and the level on the cts pin modifies the behavior of the transmitter as described below. using this m ode requires using the peripheral dma controller channel for reception. the transmitter can handle hardware handshaking in any case. figure 25-27 shows how the receiver operates if hardware handshaking is enabled. the rts pin is driven high if the receiver is disabled and if the status rxbuff (receive buffer full) com- ing from the peripheral dma controller channel is high. normally, the remote device does not start transmitting while it s cts pin (driven by rts) is high. as soon as the receiver is enabled, the rts falls, indicating to the remote device that it can start transmitting. defining a new buffer to the peripheral dma controller clears the status bit rxbuff and, as a result, asserts the pin rts low. figure 25-27. receiver behavior when operating with hardware handshaking figure 25-28 shows how the transmitter operates if hardware handshaking is enabled. the cts pin disables the transmitt er. if a character is being processi ng, the transmitter is disabled only after the completion of the current character and transmission of the next character happens as soon as the pin cts falls. figure 25-28. transmitter behavior when operating with hardware handshaking usart txd cts remote device rxd txd rxd rts rts cts rts r xbuff write cr rxen = 1 rxd rxdis = 1 cts txd
590 32117b?avr-03/11 at32uc3c 25.6.4 iso7816 mode the usart features an iso7816-compatible operating mode. this mode permits interfacing with smart cards and security access modules (sam) communicating through an iso7816 link. both t = 0 and t = 1 protocols defined by the iso7816 specification are supported. setting the usart in iso7816 mode is performed by writing the mode field in the mode regis- ter (mr) to the value 0x4 for protocol t = 0 and to the value 0x6 for protocol t = 1. 25.6.4.1 iso7816 mode overview the iso7816 is a half duplex communication on only one bidirectional line. the baud rate is determined by a division of the clo ck provided to the remote device (see ?baud rate generator? on page 568 ). the usart connects to a smart card as shown in figure 25-29 . the txd line becomes bidirec- tional and the baud rate generator feeds the iso7816 clock on the clk pin. as the txd pin becomes bidirectional, its output remains driven by the output of the transmitter but only when the transmitter is active while its input is direct ed to the input of the receiver. the usart is con- sidered as the master of the communication as it generates the clock. figure 25-29. connection of a smart card to the usart when operating in iso7816, either in t = 0 or t = 1 modes, the character format is fixed. the configuration is 8 data bits, ev en parity and 1 or 2 stop bits, regardless of the values pro- grammed in the chrl, mode9, par and chmode fields. msbf can be used to transmit lsb or msb first. parity bit (par) can be used to transmit in normal or inverse mode. refer to ?mode register? on page 628 and ?par: parity type? on page 630 . the usart cannot operate concurrently in both receiver and transmitter modes as the commu- nication is unidirectional at a time. it has to be configured according to the required mode by enabling or disabling either the receiver or the transmitter as desired. enabling both the receiver and the transmitter at the same time in iso7816 mode may lead to unpredictable results. the iso7816 specification defines an inverse transmission format. data bits of the character must be transmitted on the i/o line at their negative value. the usart does not support this for- mat and the user has to perform an exclusive or on the data before writing it in the transmit holding register (thr) or after reading it in the receive holding register (rhr). 25.6.4.2 protocol t = 0 in t = 0 protocol, a character is made up of one start bit, eight data bits, one parity bit and one guard time, which lasts two bit times. the transmitter shifts out the bits and does not drive the i/o line during the guard time. if no parity error is detected, the i/o line remains at 1 during the guard time and the transmitter can continue with the transmission of the next character, as shown in figure 25-30 . clk txd usart clk i/o smart card
591 32117b?avr-03/11 at32uc3c if a parity error is detected by the receiver, it drives the i/o line at 0 during the guard time, as shown in figure 25-31 . this error bit is also named nack, for non acknowledge. in this case, the character lasts 1 bit time more, as the guard time length is the same and is added to the error bit time which lasts 1 bit time. when the usart is the receiver and it detects an error, it does not load the erroneous character in the receive holding register (rhr). it appropriately sets the pare bit in the status register (sr) so that the software can handle the error. figure 25-30. t = 0 protocol without parity error figure 25-31. t = 0 protocol with parity error 25.6.4.3 receive error counter the usart receiver also records the total number of errors. this can be read in the number of error (ner) register. the nb_errors field ca n record up to 255 errors. reading ner auto- matically clears the nb_errors field. 25.6.4.4 receive nack inhibit the usart can also be configured to inhibit an error. this can be achieved by setting the inack bit in the mode register (mr). if inack is at 1, no error signal is driven on the i/o line even if a parity bit is detected. moreover, if inack is set, the erroneous receiv ed character is stored in the receive holding register, as if no error occurred. however, the rxrdy bit does raise. 25.6.4.5 transmit character repetition when the usart is transmitting a character and gets a nack, it can automatically repeat the character before moving on to the next one. repetition is enabled by writing the max_iteration field in the mode register (mr) at a value higher than 0. each character can be transmitted up to eight times; the firs t transmission plus seven repetitions. if max_iteration does not equal zero, the u sart repeats the character as many times as the value loaded in max_iteration. when the usart repetition number reaches max_iteration, the iteration bit is set in the channel status register (csr). if the repetition of the character is acknowledged by the receiver, the repetitions are stopped and the iteration counter is cleared. d0 d1 d2 d3 d4 d5 d6 d7 rxd parity bit baud rate clock start bit guard time 1 next start bit guard time 2 d0 d1 d2 d3 d4 d5 d6 d7 i/o parity bit baud rate clock start bit guard time 1 start bit guard time 2 d0 d1 error repetition
592 32117b?avr-03/11 at32uc3c the iteration bit in csr can be cleared by writing the control register with the rsit bit at 1. 25.6.4.6 disable successive receive nack the receiver can limit the number of successive nacks sent back to the remote transmitter. this is programmed by setting the bit dsnack in the mode register (mr). the maximum num- ber of nack transmitted is programmed in the max_iteration field. as soon as max_iteration is reached, the character is cons idered as correct, an acknowledge is sent on the line and the iteration bit in the channel status register is set. 25.6.4.7 protocol t = 1 when operating in iso7816 protocol t = 1, the transmission is similar to an asynchronous for- mat with only one stop bit. the parity is generated when transmitting and checked when receiving. parity error detection sets the par e bit in the channel status register (csr). 25.6.5 irda mode the usart features an irda mode supplying half-duplex point-to-point wireless communica- tion. it embeds the modulator and demodulator which allows a glueless connection to the infrared transceivers, as shown in figure 25-32 . the modulator and demodulator are compliant with the irda specification version 1.1 and support data transfer speeds ranging from 2.4 kb/s to 115.2 kb/s. the usart irda mode is enabled by setting the mo de field in the mode register (mr) to the value 0x8. the irda filter register (ifr) allo ws configuring the demodulator filter. the usart transmitter and receiver operate in a normal asynchronous mode and all parameters are acces- sible (except those fixed by irda specification: one start bit, 8 data bits and one stop bit). note that the modulator and the demodulator are activated. figure 25-32. connection to irda transceivers the receiver and the transmitter must be enabled or disabled according to the direction of the transmission to be managed. to receive irda signals, the following needs to be done: ? disable tx and enable rx ? configure the txd pin as i/o and set it as an output at 0 (to avoid led emission). disable the internal pull-up (better for power consumption). ? receive data irda transceivers rxd rx txd tx usart demodulator modulator receiver transmitter
593 32117b?avr-03/11 at32uc3c 25.6.5.1 irda modulation for baud rates up to and including 115.2 kbits/sec, the rzi modulation scheme is used. ?0? is represented by a light pulse of 3/16th of a bit time. some examples of signal pulse duration are shown in table 25-10 . figure 25-33 shows an example of character transmission. figure 25-33. irda modulation 25.6.5.2 irda baud rate table 25-11 gives some examples of cd values, baud rate error and pulse duration. note that the requirement on the maximum acceptable error of 1.87% must be met. table 25-10. irda pulse duration baud rate pulse duration (3/16) 2.4 kb/s 78.13 s 9.6 kb/s 19.53 s 19.2 kb/s 9.77 s 38.4 kb/s 4.88 s 57.6 kb/s 3.26 s 115.2 kb/s 1.63 s bit period bit period 3 16 start bit data bits stop bit 0 0 0 0 0 1 1 1 1 1 transmitter output txd table 25-11. irda baud rate error peripheral clock baud rate cd baud rate error pulse time 3 686 400 115 200 2 0.00% 1.63 20 000 000 115 200 11 1.38% 1.63 32 768 000 115 200 18 1.25% 1.63 40 000 000 115 200 22 1.38% 1.63 3 686 400 57 600 4 0.00% 3.26 20 000 000 57 600 22 1.38% 3.26 32 768 000 57 600 36 1.25% 3.26 40 000 000 57 600 43 0.93% 3.26 3 686 400 38 400 6 0.00% 4.88 20 000 000 38 400 33 1.38% 4.88
594 32117b?avr-03/11 at32uc3c 25.6.5.3 irda demodulator the demodulator is based on the irda receive filter co mprised of an 8-bit down counter which is loaded with the value programmed in ifr. when a falling edge is detected on the rxd pin, the filter counter starts counting down at the clk_usart speed. if a rising edge is detected on the rxd pin, the counter stops and is reloaded with ifr. if no rising edge is detected when the counter reaches 0, the input of the receiver is driven low during one bit time. figure 25-34 illustrates the operations of the irda demodulator. figure 25-34. irda demodulator operations as the irda mode uses the same logic as the iso7816, note that the fi_di_ratio field in fidi must be set to a value higher than 0 in order to assure irda communications operate correctly. 32 768 000 38 400 53 0.63% 4.88 40 000 000 38 400 65 0.16% 4.88 3 686 400 19 200 12 0.00% 9.77 20 000 000 19 200 65 0.16% 9.77 32 768 000 19 200 107 0.31% 9.77 40 000 000 19 200 130 0.16% 9.77 3 686 400 9 600 24 0.00% 19.53 20 000 000 9 600 130 0.16% 19.53 32 768 000 9 600 213 0.16% 19.53 40 000 000 9 600 260 0.16% 19.53 3 686 400 2 400 96 0.00% 78.13 20 000 000 2 400 521 0.03% 78.13 32 768 000 2 400 853 0.04% 78.13 table 25-11. irda baud rate error (continued) peripheral clock baud rate cd baud rate error pulse time clk_usart rxd counter value receiver input 654 6 3 pulse rejected 264 5 3210 pulse accepted driven low during 16 baud rate clock cycles
595 32117b?avr-03/11 at32uc3c 25.6.6 rs485 mode the usart features the rs485 mode to enable li ne driver control. while operating in rs485 mode, the usart behaves as though in asynch ronous or synchronous mode and configuration of all the parameters is possible. the differenc e is that the rts pin is driven high when the transmitter is operating. the behavior of the rts pin is controlled by the txempty bit. a typical connection of the usart to a rs485 bus is shown in figure 25-35 . figure 25-35. typical connection to a rs485 bus the usart is set in rs485 mode by programming the mode field in the mode register (mr) to the value 0x1. the rts pin is at a level inverse to the txempt y bit. significantly, the rts pin remains high when a timeguard is programmed so that the line can remain driven after the last character com- pletion. figure 25-36 gives an example of the rts waveform during a character transmission when the timeguard is enabled. figure 25-36. example of rts drive with timeguard usart rts txd rxd differential bus d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock tg = 4 write thr txrdy txempty rts
596 32117b?avr-03/11 at32uc3c 25.6.7 modem mode the usart features modem mode, which enables control of the signals: dtr (data terminal ready), dsr (data set ready), rts (request to send), cts (clear to send), dcd (data car- rier detect) and ri (ring indicator). while operating in modem mode, the usart behaves as a dte (data terminal equipment) as it drives dtr and rts and can detect level change on dsr, dcd, cts and ri. setting the usart in modem mode is performed by writing the mode field in the mode regis- ter (mr) to the value 0x3. while operating in modem mode the usart behaves as though in asynchronous mode and all the parameter configurations are available. table 25-12 gives the correspondence of the usart signals with modem connection standards. the control of the dtr output pin is performed by writing the control register (cr) with the dtrdis and dtren bits respectively at 1. th e disable command forces the corresponding pin to its inactive level, i.e. high. the enable command forces the corresponding pin to its active level, i.e. low. rts ou tput pin is automatically controlled in this mode the level changes are detected on the ri, dsr, dcd and cts pins. if an input change is detected, the riic, dsric, dcdic and ctsic bits in the channel status register (csr) are set respectively and can trigger an interrupt. the st atus is automatically cleared when csr is read. furthermore, the cts automatically disables the transmitter when it is detected at its inactive state. if a character is being transmitted when the cts rises, the character transmission is com- pleted before the transmitter is actually disabled. table 25-12. circuit references usart pin v24 ccitt direction txd 2 103 from terminal to modem rts 4 105 from terminal to modem dtr 20 108.2 from terminal to modem rxd 3 104 from modem to terminal cts 5 106 from terminal to modem dsr 6 107 from terminal to modem dcd 8 109 from terminal to modem ri 22 125 from terminal to modem
597 32117b?avr-03/11 at32uc3c 25.6.8 spi mode the serial peripheral interface (spi) mode is a synchronous serial data link that provides com- munication with external devices in master or slave mode. it also enables communication between processors if an external processor is connected to the system. the serial peripheral interface is essentially a shift register that serially transmits data bits to other spis. during a data transfer, one spi system acts as the ?master? which controls the data flow, while the other devices act as ?slaves'' whic h have data shifted into and out by the master. different cpus can take turns being masters and one master may simultaneously shift data into multiple slaves. (multiple master protocol is the opposite of single master protocol, where one cpu is always the master while all of the others are always slaves.) however, only one slave may drive its output to write data back to the master at any given time. a slave device is selected when its nss signal is asserted by the master. the usart in spi master mode can address only one spi slave bec ause it can generate only one nss signal. nevertheless the user can use standard i/o lines to access more than one spi slave. the spi system consists of two data lines and two control lines: ? master out slave in (mosi): this data line supplies the output data from the master shifted into the input of the slave. ? master in slave out (miso): this data line supplies the output data from a slave to the input of the master. ? serial clock (clk): this control line is driven by the master and regulates the flow of the data bits. the master may transmit data at a variety of baud rates. the clk line cycles once for each bit that is transmitted. ? slave select (nss): this control line allows the master to select or deselect the slave. 25.6.8.1 modes of operation the usart can operate in master mode or in slave mode. operation in spi master mode is programmed by writing at 0xe the mode field in the mode register. in this case the spi lines must be connected as described below: ? the mosi line is driven by the output pin txd ? the miso line drives the input pin rxd ? the clk line is driven by the output pin clk ? the nss line is driven by the output pin rts operation in spi slave mode is programmed by writing at 0xf the mode field in the mode reg- ister. in this case the spi lines must be connected as described below: ? the mosi line drives the input pin rxd ? the miso line is driven by the output pin txd ? the clk line drives the input pin clk ? the nss line drives the input pin cts in order to avoid unpredicted behavior, any change of the spi mode must be followed by a soft- ware reset of the transmitter and of the receiver (except the initial configuration after a hardware reset).
598 32117b?avr-03/11 at32uc3c 25.6.8.2 baud rate in spi mode, the baudrate generator operates in the same way as in usart synchronous mode: see section ?25.6.1.4? on page 570. however, there are some restrictions: in spi master mode: ? the external clock clk must not be selected (usclks 0x3), and the bit clko must be set to ?1? in the mode register (mr), in order to generate correctly the serial clock on the clk pin. ? to obtain correct behavior of the receiver and the transmitter, the value programmed in cd of must be superior or equal to 4. ? if the internal clock divided (clk_usart/div) is selected, the value programmed in cd must be even to ensure a 50:50 mark/space ratio on the clk pin, this value can be odd if the internal clock is selected (clk_usart). in spi slave mode: ? the external clock (clk) selection is forced regardless of the value of the usclks field in the mode register (mr). likewise, the value written in brgr has no effect, because the clock is provided directly by the signal on the usart clk pin. ? to obtain correct behavior of the receiver and the transmitter, the external clock (clk) frequency must be at least 4 times lower than the system clock.
599 32117b?avr-03/11 at32uc3c 25.6.8.3 data transfer up to 9 data bits are successively shifted out on the txd pin at each rising or falling edge (depending of cpol and cpha) of the programmed serial clock. there is no start bit, no parity bit and no stop bit. the number of data bits is selected by the chrl field and the mode 9 bit in the mode register (mr). the 9 bits are se lected by setting the mode 9 bit re gardless of the chrl field. the msb data bit is always sent first in spi mode (master or slave). four combinations of polarity and phase are available for data transfers. the clock polarity is programmed with the cpol bit in the mode regi ster. the clock phase is programmed with the cpha bit. these two parameters determine the edges of the clock signal upon which data is driven and sampled. each of the two parameters has two possible states, resulting in four possi- ble combinations that are incompatible with one another. thus, a master/slave pair must use the same parameter pair values to communicate. if multiple slaves are used and fixed in different configurations, the master must reconfigure itself each time it needs to communicate with a dif- ferent slave. table 25-13. spi bus protocol mode spi bus protocol mode cpol cpha 001 100 211 310
600 32117b?avr-03/11 at32uc3c figure 25-37. spi transfer format (cpha=1, 8 bits per transfer) figure 25-38. spi transfer format (cpha=0, 8 bits per transfer) clk cycle (for reference) clk (cpol= 1) mosi spi master ->txd spi slave ->rxd miso spi master ->rxd spi slave ->txd nss spi master ->rts spi slave ->cts msb msb 1 clk (cpol= 0) 3 5 6 78 lsb 1 2 3 4 6 65 5 43 21 lsb 24 clk cycle (for reference) clk (cpol= 0) clk (cpol= 1) mosi spi master -> txd spi slave -> rxd miso spi master -> rxd spi slave -> txd nss spi master -> rts spi slave -> cts msb 6 5 msb 6 5 4 43 32 21 1 lsb lsb 8 7 6 5 4 3 2 1
601 32117b?avr-03/11 at32uc3c 25.6.8.4 receiver and transmitter control see section ?25.6.2? on page 572. 25.6.8.5 character transmission the characters are sent by writing in the transmit holding register (thr). an additional condi- tion for transmitting a character can be added when the usart is configured in spi master mode. in the mr register, the value configured on inack field can prev ent any character trans- mission (even if thr has been written) while the receiver side is not ready (character not read). when inack equals 0, the character is transmitte d whatever the receiver status. if inack is set to 1, the transmitter waits for the receiver holding register to be read before transmitting the character (rxrdy flag cleared), thus preventing any overflow (c haracter loss) on the receiver side. the transmitter reports two status bits in the channel status register (csr): txrdy (transmit- ter ready), which indicates that thr is empt y and txempty, which indicates that all the characters written in thr have been processed. when the current character processing is com- pleted, the last character written in thr is transferred into the shift register of the transmitter and thr becomes empty, thus txrdy rises. both txrdy and txempty bits are low when the transmitter is disabled. writing a character in thr while txrdy is low has no effect and the written character is lost. if the usart is in spi slave mode and if a character must be sent while the transmit holding register (thr) is empty, the unre (underrun error) bit is set. the txd transmission line stays at high level during all this time. the unre bit is cleared by writing the control register (cr) with the rststa (reset status) bit at 1. in spi master mode, the slave select line (nss) is asserted at low level 1 tbit before the trans- mission of the msb bit and released at high level 1 tbit after the transmission of the lsb bit. so, the slave select line (nss) is always released be tween each character transmission and a mini- mum delay of 3 tbits always inserted. however, in order to address slave devices supporting the csaat mode (chip select active after transfer), the slave select line (nss) can be forced at low level by writing the control register (cr) with the rtsen bit at 1. the slave select line (nss) can be released at high level only by wr iting the control register (cr) with the rtsdis bit at 1 (for example, when all data have been transferred to the slave device). in spi slave mode, the transmitter does not require a falling edge of the slave select line (nss) to initiate a character transmission but only a low level. however, this lo w level must be present on the slave select line (nss) at least 1 tbit before the first serial clock cycle corresponding to the msb bit. 25.6.8.6 character reception when a character reception is completed, it is transferred to the receive holding register (rhr) and the rxrdy bit in the st atus register (csr) rises. if a character is completed while rxrdy is set, the ovre (overrun error) bit is set. the last character is transferred into rhr and overwrites the previous one. the ovre bit is cleared by writing the control register (cr) with the rststa (reset status) bit at 1. to ensure correct behavior of the receiver in spi slave mode, the master device sending the frame must ensure a minimum delay of 1 tb it between each character transmission. the receiver does not require a falling edge of the slave select line (nss) to initiate a character reception but only a low level. however, this low level must be present on the slave select line (nss) at least 1 tbit before the first serial clock cycle corresponding to the msb bit.
602 32117b?avr-03/11 at32uc3c 25.6.8.7 receiver time-out because the receiver baudrate clock is active only during data transfers in spi mode, a receiver time-out is impossible in this mode, whatever the time-out valu e is (field to) in the time-out register (rtor).
603 32117b?avr-03/11 at32uc3c 25.6.9 lin mode the lin mode provides master node and slave node connectivity on a lin bus. the lin (local interconnect network) is a serial communication protocol which efficiently sup- ports the control of mechatronic nodes in distributed automotive applications. the main properties of the lin bus are: ? single master/multiple slaves concept ? low cost silicon implementation based on common uart/sci interface hardware, an equivalent in software, or as a pure state machine. ? self synchronization without quartz or ceramic resonator in the slave nodes ? deterministic signal transmission ? low cost single-wire implementation ? speed up to 20 kbit/s lin provides cost efficient bu s communication where the bandwid th and versatility of can are not required. the lin mode enables processing lin frames with a minimum of action from the microprocessor. 25.6.9.1 modes of operation the usart can act either as a lin master node or as a lin slave node. the node configuration is chosen by setting the mode field in the mode register (mr): ? lin master node (mode=0xa) ? lin slave node (mode=0xb) in order to avoid unpredicted behavior, any change of the lin node configuration must be fol- lowed by a software reset of the transmitter and of the receiver (except the initial node configuration after a hardware reset). (see section 25.6.9.3 ) 25.6.9.2 baud rate configuration see section ?25.6.1.1? on page 568. ? lin master node: the baud rate is configured in the baud rate generator register (brgr). ? lin slave node: the initial baud rate is co nfigured in brgr, this configuration is automatically copied in the lin baud rate r egister (linbrr) when writing brgr. after synchronization procedure, the baud rate is updated in linbrr. 25.6.9.3 receiver and transmitter control see section ?25.6.2? on page 572. 25.6.9.4 character transmission see section ?25.6.3.1? on page 573. 25.6.9.5 character reception see section ?25.6.3.7? on page 581.
604 32117b?avr-03/11 at32uc3c 25.6.9.6 header transmission (master node configuration) all the lin frames start with a header which is sent by the master node and consists of a synch break field, synch field and identifier field. so in master node configuration, the frame handling starts with the sending of the header. the header is transmitted as soon as the identifier is written in the lin identifier register (linir). at this moment the flag txrdy falls. the break field, the synch field and the identif ier field are sent automatically one after the other. the break field consists of 13 dominant bits a nd 1 recessive bit, the synch field is the charac- ter 0x55 and the identifier corresponds to the character written in the lin identifier register (linir). the identifier parity bits can be automatically computed and sent (see section 25.6.9.9 ). the bit txrdy is set when the identifier character is transferred into the shift register of the transmitter. figure 25-39. header transmission txd baud rate clock start bit write linir 10101010 txrdy stop bit start bit id0 id1 id2 id3 id4 id5 id6 id7 break field 13 dominant bits (at 0) stop bit break delimiter 1 recessive bit (at 1) synch byte = 0x55 linir id
605 32117b?avr-03/11 at32uc3c 25.6.9.7 header reception (slave node configuration) all the lin frames start with a header which is sent by the master node and consists of a synch break field, synch field and identifier field. in slave node configuration, the frame handling starts with the reception of the header. the usart uses a break detection threshold of 11 nominal bit times at the actual baud rate. at any time, if 11 consecutive rece ssive bits are detected on the bus, the usart detects a break field. as long as a break field has not been detected, the usart stays idle and the received data are not taken in account. when a break field has been detected, the usar t expects the synch field character to be 0x55. this field is used to update the actual baud rate in order to stay synchronized (see section 25.6.9.8 ). if the received synch character is not 0x55, an inconsistent synch field error is gen- erated (see section 25.6.10 ). after receiving the synch field, the usart expects to receive the identifier field. when the identifier has been received, the flag linid is set to ?1?. at this moment the field idchr in the lin identifier register (linir) is updated with the re ceived character. the identifier parity bits can be automatically computed and checked (see section 25.6.9.9 ). if the header is not entirely received within the time given by the maximum length of the header theader_maximum, the error bit linhte in the channel status register (csr) is set to 1. the bits linid, linbk and linhte are reset by writing the bit rststa to 1 in the control regis- ter (cr). figure 25-40. header reception 25.6.9.8 slave node synchronization the synchronization is done only in slave node configuration. the procedure is based on time measurement between fallin g edges of the synch field. the falling edges are available in dis- tances of 2, 4, 6 and 8 bit times. figure 25-41. synch field break field 13 dominant bits (at 0) break delimiter 1 recessive bit (at 1) start bit 10101010 stop bit start bit id0 id1 id2 id4 id3 id6 id5 id7 stop bit synch byte = 0x55 baud rate clock rxd write us_cr with rststa=1 us_linir linid start bit stop bit synch field 8 tbit 2 tbit 2 tbit 2 tbit 2 tbit
606 32117b?avr-03/11 at32uc3c the time measurement is made by a 19-bit counter clocked by the sampling clock (see section 25.6.1 ). when the start bit of the synch field is detected the counter is reset. then during the next 8 tbits of the synch field, the counter is increm ented. at the end of these 8 tbits, the counter is stopped. at this moment, the 16 most significant bi ts of the counter (value divided by 8) gives the new clock divider (lincd) and the 3 least significant bits of this value (the remainder) gives the new fractional part (linfp). once the synch field has been entirely received, the clock divider (lincd) and the fractional part (linfp) are updated in the lin baud rate register (linbrr) with the computed values, if the synchronization is not disabled by the bit syncdis in the lin mode register (linmr). if after reception of the synch field, it appears that the computed baudrate deviation compared to the initial baud rate is superior to the maximum tolerance ftoi_unsynch (+/- 15%) then the clock divider (lincd) and the fractional part (linfp) are not updated and the error bit ste in the channel status register csr is set to 1. if after reception of the synch field, it appears that the sampled synch character is not equal to 0x55 then the clock divider (lincd) and the fractional part (linfp) are not updated, and the error bit isfe in the channel status register (csr) is set to 1. the bits linste and linisfe are reset by writi ng the bit rststa at 1 in the control register (cr). figure 25-42. slave node synchronization the accuracy of the synchronization depends on several parameters: ? the nominal clock frequency (f nom ) (the theoretical slave node clock frequency) ? the baudrate ? the oversampling (over=0 => 16x or over=0 => 8x) the following formula is used to compute the deviation of the slave bit rate relative to the master bit rate after synchronization (f slave is the real slave node clock frequency). rxd baud rate clock linidrx synchro counter 000_0011_0001_0110_1101 brgr clcok divider (cd) 0000_0110_0010_1101 brgr fractional part (fp) 101 initial cd initial fp reset start bit 10101010 stop bit start bit id0 id1 id2 id3 id4 id5 id6 id7 break field 13 dominant bits (at 0) stop bit break delimiter 1 recessive bit (at 1) synch byte = 0x55 baudrate_deviation 100 [ 82over ? () + ] baudrate 8f slave -------------------------------------------------------------------------------------------- - ?? ?? % =
607 32117b?avr-03/11 at32uc3c f tol_unsynch is the deviation of the real slave node clock from the nominal clock frequency. the lin standard imposes that it must not exceed 15%. the lin standard imposes also that for communication between two nodes, their bit rate must not differ by more than 2%. this means that the baudrate_deviation must not exceed 1%. it follows from that, a minimum value for the nominal clock frequency: examples: ? baudrate = 20 kbit/s, over=0 (oversampling 16x) => f nom (min) = 2.64 mhz ? baudrate = 20 kbit/s, over=1 (oversampling 8x) => f nom (min) = 1.47 mhz ? baudrate = 1 kbit/s, over=0 (oversampling 16x) => f nom (min) = 132 khz ? baudrate = 1 kbit/s, over=1 (oversampling 8x) => f nom (min) = 74 khz if the fractional baud rate is not used, the accuracy of the synchronization becomes much lower. when the counter is stopped, the 16 most significant bits of the counter (value divided by 8) gives the new clock divider (cd) . this value is rounded by adding th e first insignificant bit. the equation of the baudrate deviation is the same as given above, but the constants are as follows: it follows from that, a minimum value for the nominal clock frequency: examples: ? baudrate = 20 kbit/s, over=0 (oversampling 16x) => f nom (min) = 19.12 mhz ? baudrate = 20 kbit/s, over=1 (oversampling 8x) => f nom (min) = 9.71 mhz ? baudrate = 1 kbit/s, over=0 (oversampling 16x) => f nom (min) = 956 khz ? baudrate = 1 kbit/s, over=1 (oversampling 8x) => f nom (min) = 485 khz 25.6.9.9 identifier parity a protected identifier consists of two sub-fields; the identifier and the identifier parity. bits 0 to 5 are assigned to the identifier and bits 6 and 7 are assigned to the parity. the usart interface can generate/check these parity bits, but this feature can also be disabled. the user can choose between two modes by the pardis bit of the lin mode register (linmr): baudrate_deviation 100 [ 82over ? () + ] baudrate 8 f tol_unsynch 100 --------------------------------------- ?? ?? xf nom -------------------------------------------------------------------------------------------- - ?? ?? ?? ?? ?? % = 0.5 ? +0.5 -1 +1 << ? () 100 0.5 8 2 over ? () 1 + [] baudrate 8 15 ? 100 --------- - 1 + ?? ?? 1% ------------------------------------------------------------------------------------------------ ?? ?? ?? ?? ?? hz = 4 ? +4 -1 +1 << ? ? () 1 + [] baudrate 8 15 ? 100 --------- - 1 + ?? ?? 1% ------------------------------------------------------------------------------------------- ?? ?? ?? ?? ?? hz =
608 32117b?avr-03/11 at32uc3c ? pardis = 0: during header transmission, the parity bits are computed and sent with the 6 least significant bits of the idchr field of the lin identifier register (linir). the bits 6 and 7 of this register are discarded. during header reception, the parity bits of the identifier are checked. if the parity bits are wrong, an identifier parity error occurs (see section 25.6.3.8 ). only the 6 least significant bits of the idchr field are updated with the received iden tifier. the bits 6 and 7 are stuck at 0. ? pardis = 1: during header transmission, all th e bits of the idchr field of the lin identifier register (linir) are sent on the bus. during header reception, all the bits of the idchr field are updated with the received identifier. 25.6.9.10 node action in function of the identifier, the node is concerned, or not, by the lin response. consequently, after sending or receiving the identifier, the us art must be configured. there are three possi- ble configurations: ? publish: the node sends the response. ? subscribe: the node receives the response. ? ignore: the node is not concerned by the response, it does not send and does not receive the response. this configuration is made by the field, node action (nact), in the linmr register (see section 25.7.16 ). example: a lin cluster that contains a master and two slaves: ? data transfer from the master to the slave 1 and to the slave 2: nact(master)=publish nact(slave1)=subscribe nact(slave2)=subscribe ? data transfer from the master to the slave 1 only: nact(master)=publish nact(slave1)=subscribe nact(slave2)=ignore ? data transfer from the slave 1 to the master: nact(master)=subscribe nact(slave1)=publish nact(slave2)=ignore ? data transfer from the slave1 to the slave2: nact(master)=ignore nact(slave1)=publish nact(slave2)=subscribe
609 32117b?avr-03/11 at32uc3c ? data transfer from the slave2 to the master and to the slave1: nact(master)=subscribe nact(slave1)=subscribe nact(slave2)=publish
610 32117b?avr-03/11 at32uc3c 25.6.9.11 response data length the lin response data length is the number of data fields (bytes) of the response excluding the checksum. the response data length can either be configur ed by the user or be defined automatically by bits 4 and 5 of the identifier (compatibility to lin specification 1.1). the user can choose between these two modes by the dlm bit of the lin mode register (linmr): ? dlm = 0: the response data length is configured by the user via the dlc field of the lin mode register (linmr). the response data length is equal to (dlc + 1) bytes. dlc can be programmed from 0 to 255, so the response can contain from 1 data byte up to 256 data bytes. ? dlm = 1: the response data length is defined by the identifier (idchr in linir) according to the table below. the dlc field of the lin mode register (linmr) is discarded. the response can contain 2 or 4 or 8 data bytes. figure 25-43. response data length table 25-14. response data length if dlm = 1 idchr[5] idchr[4] response data length [bytes] 00 2 01 2 10 4 11 8 user configuration: 1 - 256 data fields (dlc+1) identifier configuration: 2/4/8 data fields sync break sync field identifier field checksum field data field data field data field data field
611 32117b?avr-03/11 at32uc3c 25.6.9.12 checksum the last field of a frame is the checksum. the checksum contains the inverted 8- bit sum with carry, over all data bytes or all data bytes and the protected identifier. checksum calculation over the data bytes only is called classic checks um and it is used for communication with lin 1.3 slaves. checksum calculation over the data by tes and the protected identifier byte is called enhanced checksum and it is used for communication with lin 2.0 slaves. the usart can be configured to: ? send/check an enhanced checksum automatically (chkdis = 0 & chktyp = 0) ? send/check a classic checksum automatically (chkdis = 0 & chktyp = 1) ? not send/check a checksum (chkdis = 1) this configuration is made by the checksum type (chktyp) and ch ecksum disable (chkdis) fields of the lin mode register (linmr). if the checksum feature is disabled, the user can send it manually all the same, by considering the checksum as a normal data byte and by adding 1 to the response data length (see section 25.6.9.11 ).
612 32117b?avr-03/11 at32uc3c 25.6.9.13 frame slot mode this mode is useful only for master nodes. it respects the following rule: each frame slot shall be longer than or equal to tframe_maximum. if the frame slot mode is enabled (fsdis = 0) and a frame transfer has been completed, the txrdy flag is set again only after tframe_maximum delay, from the start of frame. so the mas- ter node cannot send a new header if the frame slot duration of the previous frame is inferior to tframe_maximum. if the frame slot mode is disabled (fsdis = 1) and a frame transfer has been completed, the txrdy flag is set again immediately. the tframe_maximum is calculated as below: if the checksum is sent (chkdis = 0): ? theader_nominal = 34 x tbit ? tresponse_nominal = 10 x (ndata + 1) x tbit ? tframe_maximum = 1.4 x (theader_nominal + tresponse_nominal + 1) (note:) ? tframe_maximum = 1.4 x (34 + 10 x (dlc + 1 + 1) + 1) x tbit ? tframe_maximum = (77 + 14 x dlc) x tbit if the checksum is not sent (chkdis = 1): ? theader_nominal = 34 x tbit ? tresponse_nominal = 10 x ndata x tbit ? tframe_maximum = 1.4 x (theader_nominal + tresponse_nominal + 1 (note:) ) ? tframe_maximum = 1.4 x (34 + 10 x (dlc + 1) + 1) x tbit ? tframe_maximum = (63 + 14 x dlc) x tbit note: the term ?+1? leads to an integer re sult for tframe_max (lin specification 1.3) figure 25-44. frame slot mode break synch protected identifier data n checksum header inter- frame space response space frame frame slot = tframe_maximum response txrdy write thr write linid data 1 data 2 data 3 data3 data n-1 data n frame slot mode disabled frame slot mode enabled lintc data 1
613 32117b?avr-03/11 at32uc3c 25.6.10 lin errors 25.6.10.1 bit error this error is generated when usart is transmitti ng and if the transmitted value on the tx line is different from the value sampled on the rx line. if a bit error is detected, the transmission is aborted at the next byte border. this error is reported by linbe in the channel status register (csr). 25.6.10.2 inconsistent synch field error this error is generated if the synch field character received is other than 0x55. this error is reported by csr.linisfe 25.6.10.3 identifier parity error this error is generated if the parity of the identi fier is wrong. this error can be generated only if the parity feature is enabled (pardis = 0). this error is reported by csr.linipe 25.6.10.4 checksum error this error is generated if the received checksum is wrong. error bit is set to 1 only if the check- sum feature is enabled (chkdis = 0). this error is reported by csr.lince 25.6.10.5 slave not responding error this error is generated when the usart expects a response from another node (nact = sub- scribe) but no valid message appears on the bus within the time frame given by the maximum length of the message frame, tframe_maximum (see section 25.6.9.13 ). this error is disabled if the usart does not expect any message (nact = publish or nact = ignore). this error is reported by csr.linsnre 25.6.10.6 synch tolerance error this error is generated if after the clock synchr onization procedure it appears that the computed baudrate deviation compared to the initial baudrate is superior to the maximum tolerance ftoi_unsynch (+/- 15%). this error is reported by csr.linste 25.6.10.7 header time-out error this error is generated if the header is not entirely received within the time given by the maxi- mum length of the header, theader_maximum. this error is reported by csr.linhte
614 32117b?avr-03/11 at32uc3c 25.6.11 lin frame handling 25.6.11.1 master node configuration ? write txen and rxen in cr to enable both the transmitter and the receiver. ? write mode in mr to select the lin mode and the master node configuration. ? write cd and fp in brgr to configure the baud rate. ? write nact, pardis, chkdis, chktype, dlcm , fsdis and dlc in linmr to configure the frame transfer. ? check that txrdy in csr is set to ?1? ? write idchr in linir to send the header what comes next depends on the nact configuration: ? case 1: nact = publish, the usart sends the response ? wait until txrdy in csr rises ? write tchr in thr to send a byte ? if all the data have not been written, redo the two previous steps ? wait until lintc in csr rises ? check the lin errors ? case 2: nact = subscribe, the usart receives the response ? wait until rxrdy in csr rises ? read rchr in rhr ? if all the data have not been read, redo the two previous steps ? wait until lintc in csr rises ? check the lin errors ? case 3: nact = ignore, the usart is not concerned by the response ? wait until lintc in csr rises ? check the lin errors
615 32117b?avr-03/11 at32uc3c figure 25-45. master node configuration, nact = publish figure 25-46. master node configur ation, nact=subscribe frame break synch protected identifier data 1 data n checksum txrdy write thr write linir data 1 data 2 data 3 data n-1 data n rxrdy header inter- frame space response space frame slot = tframe_maximum response data3 lintc fsdis=1 fsdis=0 break synch protected identifier data 1 data n checksum txrdy read rhr write linir data 1 data n-1 data n-1 rxrdy data n data n-2 header inter- frame space response space frame frame slot = tframe_maximum response data3 lintc fsdis=0 fsdis=1
616 32117b?avr-03/11 at32uc3c figure 25-47. master node configuration, nact=ignore 25.6.11.2 slave node configuration ? write txen and rxen in cr to enable both the transmitter and the receiver. ? write mode in mr to select the lin mode and the slave node configuration. ? write cd and fp in brgr to configure the baud rate. ? wait until linid in csr rises ? check linisfe and linpe errors ? read idchr in rhr ? write nact, pardis, chkdis, chktype, dlcm and dlc in linmr to configure the frame transfer. important : if the nact configuration for this frame is publish, the us_linmr register, must be write with nact=publish even if this fiel d is already correctly configured, that in order to set the txready flag and the corresponding peripheral dma controller write transfer request. what comes next depends on the nact configuration: ? case 1: nact = publish, the usart sends the response ? wait until txrdy in csr rises ? write tchr in thr to send a byte ? if all the data have not been written, redo the two previous steps ? wait until lintc in csr rises ? check the lin errors ? case 2: nact = subscribe, the usart receives the response ? wait until rxrdy in csr rises ? read rchr in rhr ? if all the data have not been read, redo the two previous steps ? wait until lintc in csr rises ? check the lin errors txrdy write linir rxrdy lintc break synch protected identifier data 1 data n checksum data n-1 header inter- frame space response space frame frame slot = tframe_maximum response data3 fsdis=1 fsdis=0
617 32117b?avr-03/11 at32uc3c ? case 3: nact = ignore, the usart is not concerned by the response ? wait until lintc in csr rises ? check the lin errors figure 25-48. slave node configuration, nact = publish figure 25-49. slave node configuration, nact = subscribe figure 25-50. slave node configurat ion, nact = ignore break synch protected identifier data 1 data n checksum txrdy write thr read linid data 1 data 3 data n-1 data n rxrdy linidrx data 2 lintc txrdy read rhr read linid rxrdy linidrx lintc break synch protected identifier data 1 data n checksum data 1 data n-1 data n-1 data n data n-2 t xrdy read rhr read linid r xrdy l inidrx l intc break synch protected identifier data 1 data n checksum data n-1
618 32117b?avr-03/11 at32uc3c 25.6.12 lin frame handling with the peripheral dma controller the usart can be used in association with the pe ripheral dma controller in order to transfer data directly into/from the on- and off-chip memories without any processor intervention. the peripheral dma controller uses the trigger flags, txrdy and rxrdy, to write or read into the usart. the peripheral dma controller always writes in the transmit holding register (thr) and it always reads in the receive holding register (rhr). the size of the data written or read by the peripheral dma controller in the usart is always a byte. 25.6.12.1 master node configuration the user can choose between two peripheral dma controller modes by the pdcm bit in the lin mode register (linmr): ? pdcm = 1: the lin configuration is stored in the write buffer and it is written by the peripheral dma controller in the transmit holding register thr (instead of the lin mode register linmr). because the peripheral dma controller transfer size is limited to a byte, the transfer is split into two accesses. during the first access the bits, nact, pardis, chkdis, chktyp, dlm and fsdis are written. during the second access the 8-bit dlc field is written. ? pdcm = 0: the lin configuration is not stored in the write buffer and it must be written by the user in the lin mode register (linmr). the write buffer also contains the identifier and the data, if the usart sends the response (nact = publish). the read buffer contains the data if the usart receives the response (nact = subscribe). figure 25-51. master node with periphera l dma controller (pdcm=1) | | | | | | | | nact pardis chkdis chktyp dlm fsdis dlc identifier data 0 data n write buffer rxrdy peripheral bus dlc identifier data 0 data n write buffer rxrdy read buffer node action = publish node action = subscribe peripheral dma controller peripheral dma controller usart lin controller nact pardis chkdis chktyp dlm fsdis usart lin controller txrdy peripheral bus
619 32117b?avr-03/11 at32uc3c figure 25-52. master node with periphera l dma controller (pdcm=0) 25.6.12.2 slave node configuration in this configuration, the peripheral dma cont roller transfers only the data. the identifier must be read by the user in the lin identifier register (linir). the lin mode must be written by the user in the lin mode register (linmr). the write buffer contains the data if the usart sends the response (nact=publish). the read buffer contains the data if the usart receives the response (nact=subscribe). important: if the nact configuration for a fr ame is publish, the us_linmr register, must be write with nact=publish even if this field is already correctly configured, that in order to set the txready flag and the corresponding peripheral dma controller write transfer request. figure 25-53. slave node with peripheral dma controller | | | | rxrdy txrdy peripheral bus usart lin controller data 0 data n | | | | read buffer node action = publish node action = subscribe peripheral dma controller rxrdy peripheral bus data 0 data 1 data n write buffer peripheral dma controller usart lin controller | | | | | | | | data 0 data n rxrdy per ipheral bus read buffer nact = subscribe data 0 data n txrdy per ipheral bus write buffer usart lin controller usart lin controller peripheral dma controller peripheral dma controller
620 32117b?avr-03/11 at32uc3c 25.6.13 wake-up request any node in a sleeping lin cluster may request a wake-up. in the lin 2.0 specification, the wakeup reques t is issued by forcing the bus to the dominant state from 250 s to 5 ms. for this, it is necessa ry to send the character 0xf0 in order to impose 5 successive dominant bits. whatever the baud rate is, this character respects the specified timings. ? baud rate min = 1 kbit/s -> tbit = 1ms -> 5 tbits = 5 ms ? baud rate max = 20 kbit/s -> tbi t= 50 s -> 5 tbits = 250 s in the lin 1.3 specification, the wakeup request should be generated with the character 0x80 in order to impose 8 successive dominant bits. the user can choose by the wkuptyp bit in the lin mode register (linmr) either to send a lin 2.0 wakeup request (wkuptyp=0) or to send a lin 1.3 wakeup request (wkuptyp=1). a wake-up request is transmitted by writing the c ontrol register (cr) with the linwkup bit at 1. once the transfer is completed, the lintc flag is asserted in the status register (sr). it is cleared by writing the control register (cr) with the rststa bit at 1.
621 32117b?avr-03/11 at32uc3c 25.6.14 bus idle time-out if the lin bus is inactive for a certain duration, the slave nodes shall automatically enter in sleep mode. in the lin 2.0 specification, this time-out is fixed at 4 seconds. in the lin 1.3 specifica- tion, it is fixed at 25000 tbits. in slave node configuration, the receiver time -out detects an idle condition on the rxd line. when a time-out is detected, the bit timeout in the channel status register (csr) rises and can generate an interrupt, thus indicating to the driver to go into sleep mode. the time-out delay period (during which the receiver waits for a new character) is programmed in the to field of the receiver time-out register (rtor). if the to field is programmed at 0, the receiver time-out is disabled and no time-out is detected. the timeou t bit in csr remains at 0. otherwise, the receiver loads a 17-bit counter with the value programmed in to. this counter is decremented at each bit period and reloaded ea ch time a new character is received. if the counter reaches 0, the timeout bit in the status register rises. if sttto is performed, the counter clock is stopped until a first character is received. if retto is performed, the counter starts counting down immediately from the value to. table 25-15. receiver time-out programming lin specification baud rate time-out period to 2.0 1 000 bit/s 4s 4 000 2 400 bit/s 9 600 9 600 bit/s 38 400 19 200 bit/s 76 800 20 000 bit/s 80 000 1.3 - 25 000 tbits 25 000
622 32117b?avr-03/11 at32uc3c 25.6.15 test modes the usart can be programmed to operate in three different test modes. the internal loopback capability allows on-boar d diagnostics. in the loopback mode the usart interface pins are dis- connected or not and reconfigured for loopback internally or externally. 25.6.15.1 normal mode normal mode connects the rxd pin on the receiver input and the transmitter output on the txd pin. figure 25-54. normal mode configuration 25.6.15.2 automatic echo mode automatic echo mode allows bit-by-bit retransmission. when a bit is received on the rxd pin, it is sent to the txd pin, as shown in figure 25-55 . programming the transmitter has no effect on the txd pin. the rxd pin is still connected to the receiver input, thus the receiver remains active. figure 25-55. automatic echo mode configuration 25.6.15.3 local loopback mode local loopback mode c onnects the output of the transmitter directly to the input of the receiver, as shown in figure 25-56 . the txd and rxd pins are not used. the rxd pin has no effect on the receiver and the txd pin is continuously driven high, as in idle state. figure 25-56. local loopback mode configuration receiver transmitter rxd txd receiver transmitter rxd txd receiver transmitter rxd txd 1
623 32117b?avr-03/11 at32uc3c 25.6.15.4 remote loopback mode remote loopback mode directly connects the rxd pin to the txd pin, as shown in figure 25-57 . the transmitter and the receiver are disabled an d have no effect. this mode allows bit-by-bit retransmission. figure 25-57. remote loopback mode configuration receiver transmitter rxd txd 1
624 32117b?avr-03/11 at32uc3c 25.6.16 write protection registers to prevent any single software error that may corrupt usart behavior, certain address spaces can be write-protected by setting the wpen bit in the usart write protect mode register (wpmr). if a write access to the protected registers is detected, then the wpvs flag in the usart write protect status register (wpsr) is set and the field wpvsrc indicates in which regi ster the write access has been attempted. the wpvs flag is reset by writing the usart write protect mode register (wpmr) with the appropriate access key, wpkey. the protected registers are: ? ?mode register? on page 628 ? ?baud rate generator register? on page 640 ? ?receiver time-out register? on page 641 ? ?transmitter timeguard register? on page 642 ? ?fi di ratio register? on page 643 ? ?irda filter register? on page 645 ? ?manchester configuration register? on page 646
625 32117b?avr-03/11 at32uc3c 25.7 user interface note: 1. values in the version register vary wi th the version of the ip block implementation. table 25-16. usart register memory map offset register name access reset 0x0000 control register cr write-only ? 0x0004 mode register mr read-write 0x00000000 0x0008 interrupt enable register ier write-only ? 0x000c interrupt disable register idr write-only ? 0x0010 interrupt mask register imr read-only 0x00000000 0x0014 channel status register csr read-only 0x00000000 0x0018 receiver holding register rhr read-only 0x00000000 0x001c transmitter holding register thr write-only ? 0x0020 baud rate generator register brgr read-write 0x00000000 0x0024 receiver time-out register rtor read-write 0x00000000 0x0028 transmitter timeguard register ttgr read-write 0x00000000 0x0040 fi di ratio register fidi read-write 0x00000174 0x0044 number of errors re gister ner read-only 0x00000000 0x004c irda filter regi ster ifr read-write 0x00000000 0x0050 manchester encoder decoder register man read-write 0x30011004 0x0054 lin mode register linmr read-write 0x00000000 0x0058 lin identifier register linir read-write 0x00000000 0x005c lin baud rate register linbrr read-only 0x00000000 0x00e4 write protect mode register wpmr read-write 0x00000000 0x00e8 write protect status register wpsr read-only 0x00000000 0x00fc version register version read-only 0x? (1)
626 32117b?avr-03/11 at32uc3c 25.7.1 control register name: cr access type: write-only offset: 0x0 reset value: - ? linwkup: send lin wakeup signal 0: no effect: 1: sends a wakeup signal on the lin bus. ? linabt: abort lin transmission 0: no effect. 1: abort the current lin transmission. ? rtsdis/rcs: request to send disable/release spi chip select if usart does not operate in spi master mode (mode 0xe): 0: no effect. 1: drives the pin rts to 1. if usart operates in spi master mode (mode = 0xe): rcs = 0: no effect. rcs = 1: releases the slave select line nss (rts pin). ? rtsen/fcs: request to send enable/force spi chip select if usart does not operate in spi master mode (mode 0xe): 0: no effect. 1: drives the pin rts to 0. if usart operates in spi master mode (mode = 0xe): fcs = 0: no effect. fcs = 1: forces the slave select line nss (rts pin) to 0, ev en if usart is no transmitting, in order to address spi slave devices supporting the csaat mode (chip select active after transfer). ? dtrdis: data terminal ready disable 0: no effect. 1: drives the pin dtr to 1. ? dtren: data terminal ready enable 0: no effect. 1: drives the pin dtr at 0. ? retto: rearm time-out 0: no effect 1: restart time-out 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ? ? linwkup linabt rtsdis/ rcs rtsen/fcs dtrdis dtren 15 14 13 12 11 10 9 8 retto rstnack rstit senda sttto stpbrk sttbrk rststa 76543210 txdis txen rxdis rxen rsttx rstrx ? ?
627 32117b?avr-03/11 at32uc3c ? rstnack: reset non acknowledge 0: no effect 1: resets nack in csr. ? rstit: reset iterations 0: no effect. 1: resets iteration in csr. no ef fect if the iso7816 is not enabled. ? senda: send address 0: no effect. 1: in multidrop mode only, the next character writ ten to the thr is sent with the address bit set. ? sttto: start time-out 0: no effect. 1: starts waiting for a character before clocking the ti me-out counter. resets the status bit timeout in csr. ? stpbrk: stop break 0: no effect. 1: stops transmission of the break after a minimum of one characte r length and transmits a high level during 12-bit periods. no effect if no break is being transmitted. ? sttbrk: start break 0: no effect. 1: starts transmission of a break after the characters present in thr and the tr ansmit shift register have been transmitted. no effect if a break is already being transmitted. ? rststa: reset status bits 0: no effect. 1: resets the status bits pare, frame, ovre, manerr, linbe, linsfe, linipe, lince, linsnre and rxbrk in csr. ? txdis: transmitter disable 0: no effect. 1: disables the transmitter. ? txen: transmitter enable 0: no effect. 1: enables the transmitter if txdis is 0. ? rxdis: receiver disable 0: no effect. 1: disables the receiver. ? rxen: receiver enable 0: no effect. 1: enables the receiver, if rxdis is 0. ? rsttx: reset transmitter 0: no effect. 1: resets the transmitter. ? rstrx: reset receiver 0: no effect. 1: resets the receiver.
628 32117b?avr-03/11 at32uc3c 25.7.2 mode register name: mr access type: read-write offset: 0x4 reset value: - this register can only be written if the wpen bit is cleared in the write protect mode register (if exists). ? onebit: start frame delimiter selector 0: start frame delimiter is command or data sync. 1: start frame delimiter is one bit. ? modsync: manc hester synchronization mode 0:the manchester start bit is a 0 to 1 transition 1: the manchester start bit is a 1 to 0 transition. ? man: manchester encoder/decoder enable 0: manchester encoder/decoder are disabled. 1: manchester encoder/decoder are enabled. ? filter: infrared receive line filter 0: the usart does not filter the receive line. 1: the usart filters the receive line using a three-sa mple filter (1/16-bit clock) (2 over 3 majority). ? max_iteration defines the maximum number of iterations in mode iso7816, protocol t= 0. ? invdata: inverted data 0: the data field transmitted on tx d line is the same as the one written in thr register or the content read in rhr is the same as rxd line. normal mode of operation. 1: the data field transmitted on txd line is inverted (voltage po larity) compared to the value wr itten in thr register or the content read in rhr is inverted compared to rxd line (or iso781 6 io line). inverted mode of operation, useful for contactless card application. to be used with configuration bit msbf. ? var_sync: variable synchronization of co mmand/data sync start frame delimiter 0: user defined configuration of comma nd or data sync field depending on sync value. 1: the sync field is updated when a char acter is written into thr register. ? dsnack: disable successive nack 0: nack is sent on the iso line as soon as a parity error occurs in the received character (unless inack is set). 1: successive parity errors are counted up to the value specifi ed in the max_iteration field. these parity errors generate a nack on the iso line. as soon as this value is reached, no addi tional nack is sent on the iso line. the flag iteration is asserted. 31 30 29 28 27 26 25 24 onebit modsync man filter ? max_iteration 23 22 21 20 19 18 17 16 invdata var_sync dsnack inack over clko mode9 msbf/cpol 15 14 13 12 11 10 9 8 chmode nbstop par sync/cpha 76543210 chrl usclks mode
629 32117b?avr-03/11 at32uc3c ? inack: inhibit non acknowledge 0: the nack is generated. 1: the nack is not generated. note: in spi master mode, if inack = 0 th e character transmission starts as soon as character is written into thr register (assuming txrdy was set). when inack = 1, an additional condition must be met. the character transmission starts when a character is written and only if rxrdy bit is cleared (rhr has been read). ? over: oversampling mode 0: 16x oversampling. 1: 8x oversampling. ? clko: clock output select 0: the usart does not drive the clk pin. 1: the usart drives the clk pin if usclks does not select the external clock clk. ? mode9: 9-bit character length 0: chrl defines character length. 1: 9-bit character length. ? msbf/cpol: bit order or spi clock polarity if usart does not operate in spi mode (mode 0xe and 0xf): msbf = 0: least significant bit is sent/received first. msbf = 1: most significant bit is sent/received first. if usart operates in spi mode (slave or master, mode = 0xe or 0xf): cpol = 0: the inactive state value of spck is logic level zero. cpol = 1: the inactive state va lue of spck is logic level one. cpol is used to determine the inactive state value of the seri al clock (spck). it is used with cpha to produce the required clock/data relationship between master and slave devices. ? chmode: channel mode ? nbstop: number of stop bits table 25-17. chmode mode description 0 0 normal mode 0 1 automatic echo. receiver input is connected to the txd pin. 1 0 local loopback. transmitter output is connected to the receiver input. 1 1 remote loopback. rxd pin is internally connected to the txd pin. table 25-18. nbstop asynchronous (sync = 0) synchronous (sync = 1) 0 0 1 stop bit 1 stop bit 0 1 1.5 stop bits reserved 1 0 2 stop bits 2 stop bits 1 1 reserved reserved
630 32117b?avr-03/11 at32uc3c ? par: parity type ? sync/cpha: synchronous mode select or spi clock phase if usart does not operate in spi mode (mode is 0xe and 0xf): sync = 0: usart operates in asynchronous mode. sync = 1: usart operates in synchronous mode. if usart operates in spi mode (mode = 0xe or 0xf): cpha = 0: data is changed on the leading edge of spck and captured on the following edge of spck. cpha = 1: data is captured on the leading edge of spck and changed on the following edge of spck. cpha determines which edge of spck causes data to change an d which edge causes data to be captured. cpha is used with cpol to produce the required clock/data rela tionship between master and slave devices. ? chrl: character length. ? usclks: clock selection note: 1. the value of div is device dependent. please re fer to the module confi guration section at the end of this chapter. table 25-19. par parity type 0 0 0 even parity 001odd parity 0 1 0 parity forced to 0 (space) 0 1 1 parity forced to 1 (mark) 1 0 x no parity 1 1 x multidrop mode table 25-20. chrl character length 0 0 5 bits 0 1 6 bits 1 0 7 bits 1 1 8 bits table 25-21. usclks selected clock 0 0 clk_usart 0 1 clk_usart/div (1) 10reserved 11 clk
631 32117b?avr-03/11 at32uc3c ? mode table 25-22. mode mode of the usart 0000normal 0001rs485 0 0 1 0 hardware handshaking 0011modem 0 1 0 0 is07816 protocol: t = 0 0 1 1 0 is07816 protocol: t = 1 1000irda 1 0 1 0 lin master 1011lin slave 1110spi master 1 1 1 1 spi slave others reserved
632 32117b?avr-03/11 at32uc3c 25.7.3 interrupt enable register name: ier access type: write-only offset: 0x8 reset value: - writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. for backward compatibility the mane bit has been duplicated to the manea bit position . writing either o ne or the other has the same effect. 31 30 29 28 27 26 25 24 linhte linste linsnre lince li nipe linisfe linbe manea 23 22 21 20 19 18 17 16 ? ? ? mane ctsic dcdic dsric riic 15 14 13 12 11 10 9 8 lintc linid nack/linbk rxbuff ? iter/unre txempty timeout 76543210 pare frame ovre ? ? rxbrk txrdy rxrdy
633 32117b?avr-03/11 at32uc3c 25.7.4 interrupt disable register name: idr access type: write-only offset: 0xc reset value: - writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. for backward compatibility the mane bit has been duplicated to the manea bit position . writing either o ne or the other has the same effect. 31 30 29 28 27 26 25 24 linhte linste linsnre lince li nipe linisfe linbe manea 23 22 21 20 19 18 17 16 ? ? ? mane ctsic dcdic dsric riic 15 14 13 12 11 10 9 8 lintc linid nack/linbk rxbuff ? iter/unre txempty timeout 76543210 pare frame ovre ? ? rxbrk txrdy rxrdy
634 32117b?avr-03/11 at32uc3c 25.7.5 interrupt mask register name: imr access type: read-only offset: 0x10 reset value: - 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. for backward compatibility the mane bit has been duplicated to the manea bit position. r eading either one or the other has the same effect. 31 30 29 28 27 26 25 24 linhte linste linsnre lince li nipe linisfe linbe manea 23 22 21 20 19 18 17 16 ? ? ? mane ctsic dcdic dsric riic 15 14 13 12 11 10 9 8 lintc linid nack/linbk rxbuff ? iter/unre txempty timeout 76543210 pare frame ovre ? ? rxbrk txrdy rxrdy
635 32117b?avr-03/11 at32uc3c 25.7.6 channel status register name: csr access type: read-only offset: 0x14 reset value: - ? linhte: lin header time-out error 0: no lin header time-out error has been detected since the last rststa. 1: a lin header time-out error has been detected since the last rststa. ? linste: lin synch tolerance error 0: no lin synch tolerance error has been detected since the last rststa. 1: a lin synch tolerance error has been detected since the last rststa. ? linsnre: lin slave not responding error 0: no lin slave not responding error has been detected since the last rststa. 1: a lin slave not responding error has been detected since the last rststa. ? lince: lin checksum error 0: no lin checksum error has been detected since the last rststa. 1: a lin checksum error has been detected since the last rststa. ? linipe: lin identifi er parity error 0: no lin identifier parity error has been detected since the last rststa. 1: a lin identifier parity error has been detected since the last rststa. ? linisfe: lin inconsistent synch field error 0: no lin inconsistent synch field erro r has been detected since the last rststa 1: the usart is configured as a slave node and a lin incons istent synch field error has been detected since the last rststa. ? linbe: lin bit error 0: no bit error has been detected since the last rststa. 1: a bit error has been detected since the last rststa. ? manerr: manchester error 0: no manchester error has been detected since the last rststa. 1: at least one manchester error has been detected since the last rststa. ? cts/linbls: image of cts input or lin bus line status ? if usart does not operate in lin mode (master or slave): 0: cts is at 0. 1: cts is at 1. ? if usart operates in lin mode (master or slave): 31 30 29 28 27 26 25 24 linhte linste linsnre lince li nipe linisfe linbe manerr 23 22 21 20 19 18 17 16 cts/linbls dcd dsr ri ctsic dcdic dsric riic 15 14 13 12 11 10 9 8 lintc linid nack/linbk rxbuff ? iter/unre txempty timeout 76543210 pare frame ovre ? ? rxbrk txrdy rxrdy
636 32117b?avr-03/11 at32uc3c 0: lin bus line is at 0. 1: lin bus line is at 1. ? dcd: image of dcd input 0: dcd is at 0. 1: dcd is at 1. ? dsr: image of dsr input 0: dsr is at 0. 1: dsr is at 1. ? ri: image of ri input 0: ri is at 0. 1: ri is at 1. ? ctsic: clear to send input change flag 0: no input change has been detected on th e cts pin since the last read of csr. 1: at least one input change has been detect ed on the cts pin since the last read of csr. ? dcdic: data carrier detect input change flag 0: no input change has been detected on the dcd pin since the last read of csr. 1: at least one input change has been detect ed on the dcd pin since the last read of csr. ? dsric: data set read y input change flag 0: no input change has been detected on the dsr pin since the last read of csr. 1: at least one input change has been detected on the dsr pin since the last read of csr. ? riic: ring indicator input change flag 0: no input change has been detected on th e ri pin since the last read of csr. 1: at least one input change has been detect ed on the ri pin since the last read of csr. ? lintc: lin transfer completed 0: the usart is idle or a lin transfer is ongoing. 1: a lin transfer has been comp leted since the last rststa. ? linid: lin identifier 0: no lin identifier received or sent 1: the usart is configured as a slave node and a lin identifier has been received or the usart is configured as a master node and a lin identifier has been sent since the last rststa. ? nack: non acknowledge 0: no non acknowledge has not been detected since the last rstnack. 1: at least one non acknowledge has been detected since the last rstnack. ? rxbuff: reception buffer full 0: the signal buffer full from the receive peripheral dma controller channel is inactive. 1: the signal buffer full from the receive peripheral dma controller channel is active. ? iter/unre: max number of repetitions reached or spi underrun error if usart does not operate in spi slave mode (mode 0xf): iter = 0: maximum number of repetitions has not been reached since the last rststa. iter = 1: maximum number of repetitions has been reached since the last rststa. if usart operates in spi slave mode (mode = 0xf): unre = 0: no spi underrun error has occurred since the last rststa. unre = 1: at least one spi underrun error has occurred since the last rststa. ? txempty: transmitter empty 0: there are characters in either thr or the tran smit shift register, or the transmitter is disabled. 1: there are no characters in thr, nor in the transmit shift register. ? timeout: receiver time-out 0: there has not been a time-out since the last start time-o ut command (sttto in cr) or the time-out register is 0. 1: there has been a time-out since the last start time-out command (sttto in cr). ? pare: parity error
637 32117b?avr-03/11 at32uc3c 0: no parity error has been det ected since the last rststa. 1: at least one parity error has been detected since the last rststa. ? frame: framing error 0: no stop bit has been detected low since the last rststa. 1: at least one stop bit has been det ected low since the last rststa. ? ovre: overrun error 0: no overrun error has occurred since the last rststa. 1: at least one overrun error has occurred since the last rststa. ? rxbrk: break received/end of break 0: no break received or end of break detected since the last rststa. 1: break received or end of brea k detected since the last rststa. ? txrdy: transmitter ready 0: a character is in the thr waiting to be transferred to the transmit shift register, or an sttbrk command has been requested, or the transmitter is disabled. as so on as the transmitter is enabled, txrdy becomes 1. 1: there is no character in the thr. ? rxrdy: receiver ready 0: no complete character has been received since the last read of rhr or the receiver is disabled. if characters were being received when the receiver was disabled, rxrdy changes to 1 when the receiver is enabled. 1: at least one complete character has been received and rhr has not yet been read.
638 32117b?avr-03/11 at32uc3c 25.7.7 receive holding register name: rhr access type: read-only offset: 0x18 reset value: 0x00000000 ? rxsynh: received sync 0: last character received is a data. 1: last character received is a command. ? rxchr: received character last character received if rxrdy is set. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 rxsynh ??????rxchr 76543210 rxchr
639 32117b?avr-03/11 at32uc3c 25.7.8 usart transmit holding register name: thr access type: write-only offset: 0x1c reset value: - ? txsynh: sync field to be transmitted 0: the next character sent is encoded as a data. start frame delimiter is data sync. 1: the next character sent is encoded as a co mmand. start frame deli miter is command sync. ? txchr: character to be transmitted next character to be transmitted after the current character if txrdy is not set. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 txsynh ??????txchr 76543210 txchr
640 32117b?avr-03/11 at32uc3c 25.7.9 baud rate generator register name: brgr access type: read-write offset: 0x20 reset value: 0x00000000 this register can only be written if the wpen bit is cleared in the write protect mode register. ? fp: fractional part 0: fractional divider is disabled. 1 - 7: baudrate resolution, defined by fp x 1/8. ? cd: clock divider 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????? fp 15 14 13 12 11 10 9 8 cd 76543210 cd table 25-23. cd mode iso7816 mode = iso7816 sync = 0 sync = 1 or mode = spi (master or slave) over = 0 over = 1 0 baud rate clock disabled 1 to 65535 baud rate = selected clock/16/cd baud rate = selected clock/8/cd baud rate = selected clock /cd baud rate = selected clock/cd/fi_di_ratio
641 32117b?avr-03/11 at32uc3c 25.7.10 receiver time-out register name: rtor access type: read-write offset: 0x24 reset value: 0x00000000 this register can only be written if the wpen bit is cleared in the write protect mode register. ? to: time-out value 0: the receiver time-out is disabled. 1 - 131071: the receiver time-out is enabled and the time-out delay is to x bit period. note that the size of the to counter can change depending of implementation. see the mo dule configuration section. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????to 15 14 13 12 11 10 9 8 to 76543210 to
642 32117b?avr-03/11 at32uc3c 25.7.11 transmitter timeguard register name: ttgr access type: read-write offset: 0x28 reset value: 0x00000000 this register can only be written if the wpen bit is cleared in the write protect mode register. ? tg: timeguard value 0: the transmitter timeguard is disabled. 1 - 255: the transmitter timeguard is enabled and the timeguard delay is tg x bit period. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 tg
643 32117b?avr-03/11 at32uc3c 25.7.12 fi di ratio register name: fidi access type: read-write offset: 0x40 reset value: 0x00000174 this register can only be written if the wpen bit is cleared in the write protect mode register. ? fi_di_ratio: fi over di ratio value 0: if iso7816 mode is selected, the baud rate generator generates no signal. 1 - 2047: if iso7816 mode is selected, the baud rate is the clock provided on clk divided by fi_di_ratio. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????? fi_di_ratio 76543210 fi_di_ratio
644 32117b?avr-03/11 at32uc3c 25.7.13 number of errors register name: ner access type: read-only offset: 0x44 reset value: - ? nb_errors: number of errors total number of errors that occurred during an iso7816 tr ansfer. this register automatically clears when read. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 nb_errors
645 32117b?avr-03/11 at32uc3c 25.7.14 irda filter register name: ifr access type: read-write offset: 0x4c reset value: 0x00000000 this register can only be written if the wpen bit is cleared in the write protect mode register (if exists). irda_filter: irda filter sets the filter of the irda demodulator. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 irda_filter
646 32117b?avr-03/11 at32uc3c 25.7.15 manchester configuration register name: man access type: read-write offset: 0x50 reset value: 0x30011004 this register can only be written if the wpen bit is cleared in the write protect mode register (if exists). ? drift: drift compensation 0: the usart can not recover fr om an important clock drift 1: the usart can recover from clock drift. the 16x clock mode must be enabled. ? rx_mpol: receiver manchester polarity 0: logic zero is coded as a zero-to-one transition, logic one is coded as a one-to-zero transition. 1: logic zero is coded as a one-to-zero transition, logic one is coded as a zero-to-one transition. ? rx_pp: receiver preamble pattern detected ? rx_pl: receiver preamble length 0: the receiver preamble pattern detection is disabled 1 - 15: the detected preamble length is rx_pl x bit period ? tx_mpol: transmitter manchester polarity 0: logic zero is coded as a zero-to-one transition, logic one is coded as a one-to-zero transition. 1: logic zero is coded as a one-to-zero transition, logic one is coded as a zero-to-one transition. 31 30 29 28 27 26 25 24 ? drift 1 rx_mpol ? ? rx_pp 23 22 21 20 19 18 17 16 ???? rx_pl 15 14 13 12 11 10 9 8 ? ? ? tx_mpol ? ? tx_pp 76543210 ???? tx_pl table 25-24. rx_pp preamble pattern de fault polarity assumed (rx_mpol fi eld not set) 0 0 all_one 0 1 all_zero 10zero_one 11one_zero
647 32117b?avr-03/11 at32uc3c ? tx_pp: transmitter preamble pattern ? tx_pl: transmitter preamble length 0: the transmitter preamble pattern generation is disabled 1 - 15: the preamble length is tx_pl x bit period table 25-25. tx_pp preamble pattern default polari ty assumed (tx_mpol field not set) 0 0 all_one 0 1 all_zero 10zero_one 11one_zero
648 32117b?avr-03/11 at32uc3c 25.7.16 lin mode register name: linmr access type: read-write offset: 0x54 reset value: 0x00000000 ? syncdis: synchronization disable 0: the synchronization procedure is pe rformed in lin slave node configuration. 1: the synchronization procedure is not performed. ? pdcm: peripheral dma controller mode 0: the lin mode register linmr is not written by the peripheral dma controller. 1: the lin mode register linmr (excepting that bi t) is written by the peripheral dma controller. ? dlc: data length control 0 - 255: defines the response data length if dlm=0,in th at case the response data length is equal to dlc+1 bytes. ? wkuptyp: wakeup signal type 0: setting the bit linwkup in the contro l register sends a lin 2.0 wakeup signal. 1: setting the bit linwkup in the contro l register sends a lin 1.3 wakeup signal. ? fsdis: frame slot mode disable 0: the frame slot mode is enabled. 1: the frame slot mode is disabled. ? dlm: data length mode 0: the response data length is defined by the field dlc of this register. 1: the response data length is defined by the bi ts 4 and 5 of the ident ifier (idchr in linir). ? chktyp: checksum type 0: lin 2.0 ?enhanced? checksum 1: lin 1.3 ?classic? checksum ? chkdis: checksum disable 0: in master node configuration, the checksum is computed and sent automatically. in slave node configuration, the checksum is checked automatically. 1: whatever the node configuration is, the checks um is not computed/sent and it is not checked. ? pardis: parity disable 0: in master node configuration, the identifier parity is computed and sent automatically. in master node and slave node configuration, the parity is checked automatically. 1:whatever the node configuration is , the identifier parity is not com puted/sent and it is not checked. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ??????sy ncdis pdcm 15 14 13 12 11 10 9 8 dlc 76543210 wkuptyp fsdis dlm chktyp chkdis pardis nact
649 32117b?avr-03/11 at32uc3c ? nact: lin node action table 1. nact mode description 0 0 publish: the usart transmits the response. 0 1 subscribe: the usart receives the response. 1 0 ignore: the usart does not transmit and does not receive the response. 11reserved
650 32117b?avr-03/11 at32uc3c 25.7.17 lin identifier register name: linir access type: read-write or read-only offset: 0x58 reset value: 0x00000000 ? idchr: identifier character if mode=0xa (master node configuration): idchr is read-write and its value is the identifier character to be transmitted. if mode=0xb (slave node configuration): idchr is read-only and its value is the last identifier character that has been received. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 idchr
651 32117b?avr-03/11 at32uc3c 25.7.18 lin baud rate register name: linbrr access type: read-only offset: 0x5c reset value: 0x00000000 ? linfp: lin fractional part after synchronization ? lincd: lin clock divider after synchronization 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????? linfp 15 14 13 12 11 10 9 8 lincd 76543210 lincd
652 32117b?avr-03/11 at32uc3c 25.7.19 write protect mode register register name: wpmr access type: read-write offset: 0xe4 reset value: see table 25-16 ? wpkey: write protect key should be written at value 0x555341 ("usa" in ascii). writing an y other value in this field aborts the write operation of the wpen bit. always reads as 0. ? wpen: write protect enable 0 = disables the write protect if wpkey corre sponds to 0x555341 ("usa" in ascii). 1 = enables the write protect if wpkey corr esponds to 0x555341 ("usa" in ascii). protects the registers: ? ?mode register? on page 628 ? ?baud rate generator register? on page 640 ? ?receiver time-out register? on page 641 ? ?transmitter timeguard register? on page 642 ? ?fi di ratio register? on page 643 ? ?irda filter register? on page 645 ? ?manchester configuration register? on page 646 31 30 29 28 27 26 25 24 wpkey 23 22 21 20 19 18 17 16 wpkey 15 14 13 12 11 10 9 8 wpkey 76543210 ???????wpen
653 32117b?avr-03/11 at32uc3c 25.7.20 write protect status register register name: wpsr access type: read-only offset: 0xe8 reset value: see table 25-16 ? wpvsrc: write protect violation source when wpvs is active, this field indicates the write- protected register (through address offs et or code) in which a write access has been attempted. ? wpvs: write protect violation status 0 = no write protect violation has occurred since the last read of the wpsr register. 1 = a write protect violation has occurred si nce the last read of the wpsr register. if this violation is an unauthorized attem pt to write a protected register, the associated violation is reported into field wpvsrc. note: reading wpsr automatically clears all fields. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 wpvsrc 15 14 13 12 11 10 9 8 wpvsrc 76543210 ???????wpvs
654 32117b?avr-03/11 at32uc3c 25.7.21 version register name: version access type: read-only offset: 0xfc reset value: - ? mfn reserved. no functionality associated. ? version version of the module. no functionality associated. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???? mfn 15 14 13 12 11 10 9 8 ???? version 76543210 version
655 32117b?avr-03/11 at32uc3c 25.8 module configuration the specific configuration for each usart instance is listed in the following tables. the module bus clocks listed here are connected to the system bus clocks according to the table in the sys- tem bus clock connections section. 25.8.1 clock connections each usart can be connected to an internally divided clock: table 25-26. module configuration feature usart0 usart2 usart3 usart4 usart1 iso7816 not implemented implemented irda logic not implemented implemented rs485 logic not implemented implemented modem logic not implemented implemented spi logic implemented implemented lin logic implemented implemented manchester logic not implemented implemented fractional baudrate implemented implemented div value for divided clk_usart 8 8 receiver time-out counter size (size of the rtor.to field) 17-bits 17-bits table 25-27. module clock name module name clock name description usart0 clk_usart0 peripheral bus clock from the pba clock domain usart1 clk_usart1 peripheral bus clock from the pbc clock domain usart2 clk_usart2 peripheral bus clock from the pba clock domain usart3 clk_usart3 peripheral bus clock from the pba clock domain usart4 clk_usart4 peripheral bus clock from the pbc clock domain table 25-28. usart clock connections usart source name connection 0 internal clk_div pba clock / 8 (clk_pba_usart_div) 1 pbc clock / 8 (clk_pbc_usart_div) 2 pba clock / 8 (clk_pba_usart_div) 3 pba clock / 8 (clk_pba_usart_div) 4 pbc clock / 8 (clk_pbc_usart_div)
656 32117b?avr-03/11 at32uc3c 25.8.2 register reset values table 25-29. register reset values register reset value version 0x00000602
657 32117b?avr-03/11 at32uc3c 26. serial peripheral interface (spi) rev: 2.1.1.3 26.1 features ? compatible with an embedded 32-bit microcontroller ? supports communication with serial external devices ? four chip selects with extern al decoder support allow co mmunication with up to 15 peripherals ? serial memories, such as da taflash and 3-wire eeproms ? serial peripherals, such as adcs, dacs, l cd controllers, can controllers and sensors ? external co-processors ? master or slave serial peripheral bus interface ? 4 - to 16-bit programmable da ta length per chip select ? programmable phase and polarity per chip select ? programmable transfer delays between consecutive transfers and between clock and data per chip select ? programmable delay between consecutive transfers ? selectable mode fault detection ? connection to peripheral dma controller ch annel capabilities opti mizes data transfers ? one channel for the receiver, one channel for the transmitter ? next buffer support ? four character fifo in reception 26.2 overview the serial peripheral interface (spi) circuit is a synchronous serial data link that provides com- munication with external devices in master or slave mode. it also enables communication between processors if an external processor is connected to the system. the serial peripheral interface is essentially a shift register that serially transmits data bits to other spis. during a data transfer, one spi syste m acts as the ?master?' which controls the data flow, while the other devices act as ?slaves'' whic h have data shifted into and out by the master. different cpus can take turn being masters (multiple master protocol opposite to single master protocol where one cpu is always the master while all of the others are always slaves) and one master may simultaneously shift da ta into multiple slaves. howeve r, only one slave may drive its output to write data back to the master at any given time. a slave device is selected when the master asse rts its nss signal. if multiple slave devices exist, the master generates a separate slav e select signal for each slave (npcs). the spi system consists of two data lines and two control lines: ? master out slave in (mosi): this data line supplies the output data from the master shifted into the input(s) of the slave(s). ? master in slave out (miso): this data line supplies the output data from a slave to the input of the master. there may be no more than one slave transmitting data during any particular transfer. ? serial clock (spck): this contro l line is driven by the master and regulates the flow of the data bits. the master may transmit data at a variety of baud rates; the spck line cycles once for each bit that is transmitted. ? slave select (nss): this control line allows slaves to be turned on and off by hardware.
658 32117b?avr-03/11 at32uc3c 26.3 block diagram figure 26-1. spi block diagram 26.4 application block diagram figure 26-2. application block diagram: single master/multiple slave implementation spi interface interrupt control peripheral dma controller i/o controller clk_spi peripheral bus spi interrupt spck npcs3 npcs2 npcs1 npcs0/nss mosi miso slave 0 slave 2 slave 1 spck npcs3 npcs2 npcs1 npcs0 mosi miso spi master spck nss mosi miso spck nss mosi miso spck nss mosi miso nc
659 32117b?avr-03/11 at32uc3c 26.5 i/o lines description 26.6 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 26.6.1 i/o lines the pins used for interfacing the compliant external devices may be multiplexed with i/o lines. the user must first configure the i/o controll er to assign the spi pins to their peripheral functions. 26.6.2 clocks the clock for the spi bus interface (clk_spi) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to disable the spi before disabling the clock, to avoid freezing the spi in an undefined state. 26.6.3 interrupts the spi interrupt request line is connected to the interrupt controller. using the spi interrupt requires the interrupt controller to be programmed first. 26.7 functional description 26.7.1 modes of operation the spi operates in master mode or in slave mode. operation in master mode is configured by writing a one to the master/slave mode bit in the mode register (mr.mstr). the pins npcs0 to npcs3 are all configured as outputs, the spck pin is driven, the miso line is wired on the rece iver input and the mosi line driven as an output by the transmitter. if the mr.mstr bit is written to zero, the spi ope rates in slave mode. the miso line is driven by the transmitter output, the mosi line is wired on the receiver input, the spck pin is driven by the transmitter to synchronize the receiver. the npcs0 pin becomes an input, and is used as a slave select signal (nss). the pins npcs1 to npcs3 are not driven and can be used for other purposes. the data transfers are identically programmable for both modes of operations. the baud rate generator is activated only in master mode. table 26-1. i/o lines description pin name pin description type master slave miso master in slave out input output mosi master out slave in output input spck serial clock output input npcs1-npcs3 peripheral chip selects output unused npcs0/nss peripheral chip select/slave select output input
660 32117b?avr-03/11 at32uc3c 26.7.2 data transfer four combinations of polarity and phase are available for data transfers. the clock polarity is configured with the clock polarity bit in the chip select registers (csrn.cpol). the clock phase is configured with the clock phase bit in the csrn registers (csrn.ncpha). these two bits determine the edges of the clock signal on which data is driven and sampled. each of the two bits has two possible states, resulting in four possible combinations that are incompatible with one another. thus, a master/slave pair must use the same parameter pair values to com- municate. if multiple slaves are used and fix ed in different configurations, the master must reconfigure itself each time it needs to communicate with a different slave. table 26-2 on page 660 shows the four modes and corresponding parameter settings. figure 26-3 on page 660 and figure 26-4 on page 661 show examples of data transfers. figure 26-3. spi transfer format (ncpha = 1, 8 bits per transfer) table 26-2. spi modes spi mode cpol ncpha 001 100 211 310 14 3 2 58 7 6 spck cycle (for reference) spck (cpol = 0) nss (to slave) miso (from slave) mosi (from master) spck (cpol = 1) msb 6 4 5lsb 1 2 3 msb 6 *** lsb 1 2 3 4 5 *** not defined, but normaly msb of previous character received
661 32117b?avr-03/11 at32uc3c figure 26-4. spi transfer format (ncpha = 0, 8 bits per transfer) 26.7.3 master mode operations when configured in master mode, the spi uses the internal programmable baud rate generator as clock source. it fully controls the data transfers to and from the slave(s) connected to the spi bus. the spi drives the chip select line to the slave and the serial clock signal (spck). the spi features two holding registers, the tr ansmit data register (tdr) and the receive data register (rdr), and a single shi ft register. the holding registers maintain the data flow at a constant rate. after enabling the spi, a data transfer begins when the processor writes to the tdr register. the written data is immediately transferred in the shift register and transfer on the spi bus starts. while the data in the shift register is shifted on the mosi line, the miso line is sampled and shifted in the shift register. transmission cannot occur without reception. before writing to the tdr, the peripheral chip select field in tdr (tdr.pcs) must be written in order to select a slave. if new data is written to tdr during the transfer, it stays in it until the current transfer is com- pleted. then, the received data is transferred from the shift register to rdr, the data in tdr is loaded in the shift register and a new transfer starts. the transfer of a data written in tdr in the shift register is indicated by the transmit data reg- ister empty bit in the status register (sr.tdre). when new data is written in tdr, this bit is cleared. the sr.tdre bit is used to trigger the transmit peripheral dma controller channel. the end of transfer is indicated by the transmission registers empty bit in the sr register (sr.txempty). if a transfer delay (csrn.dlybct) is greater than zero for the last transfer, sr.txempty is set after the completion of said delay. the clk_spi can be switched off at this time. during reception, received data are transferred from the shift register to the reception fifo. the fifo can contain up to 4 characters (both receive data and peripheral chip select fields). while a character of the fifo is unread, the receive data register full bit in sr remains high (sr.rdrf). characters are read through the rdr re gister. if the four char acters stored in the fifo are not read and if a new character is stored, this sets the overrun error status bit in the sr register (sr.ovres). the procedure to follow in such a case is described in section 26.7.3.8 . 14 3 2 58 7 6 spck cycle (for reference) spck (cpol = 0) nss (to slave) miso (from slave) mosi (from master) spck (cpol = 1) msb 6 4 5lsb 1 2 3 6 lsb 1 2 3 4 5 *** not defined, but normaly lsb of previous character transmitted msb ***
662 32117b?avr-03/11 at32uc3c figure 26-5 on page 662 shows a block diagram of the spi when operating in master mode. fig- ure 26-6 on page 663 shows a flow chart describing how transfers are handled. 26.7.3.1 master mode block diagram figure 26-5. master mode block diagram baud rate generator rxfifoen 4 ? character fifo shift register tdre rxfifoen 4 ? character fifo ps pcsdec current peripheral modf modfdis mstr scbr csr0..3 csr0..3 cpol ncpha bits rdr rd rdrf ovres td tdr rdr csaat csnaat csr0..3 pcs mr pcs tdr spck clk_spi miso mosi msb lsb npcs1 npcs2 npcs3 npcs0 spi clock 0 1 0 1 0 1 npcs0
663 32117b?avr-03/11 at32uc3c 26.7.3.2 master mode flow diagram figure 26-6. master mode flow diagram spi enable csaat ? ps ? 1 0 0 1 1 npcs = tdr(pcs) npcs = mr(pcs) delay dlybs serializer = tdr(td) tdre = 1 data transfer rdr(rd) = serializer rdrf = 1 tdre ? npcs = 0xf delay dlybcs fixed peripheral variable peripheral delay dlybct 0 1 csaat ? 0 tdre ? 1 0 ps ? 0 1 tdr(pcs) = npcs ? no yes mr(pcs) = npcs ? no npcs = 0xf delay dlybcs npcs = tdr(pcs) npcs = 0xf delay dlybcs npcs = mr(pcs), tdr(pcs) fixed peripheral variable peripheral - npcs defines the current chip select - csaat, dlybs, dlybct refer to the fields of the chip select register corresponding to the current chip select - when npcs is 0xf, csaat is 0.
664 32117b?avr-03/11 at32uc3c 26.7.3.3 clock generation the spi baud rate clock is generated by dividing the clk_spi , by a value between 1 and 255. this allows a maximum operating baud rate at up to clk_spi and a minimum operating baud rate of clk_spi divided by 255. writing the serial clock baud rate field in the csrn registers (csrn.scbr) to zero is forbid- den. triggering a transfer while csrn.scbr is zero can lead to unpredictable results. at reset, csrn.scbr is zero and the user has to configure it at a valid value before performing the first transfer. the divisor can be defined independently for each chip select, as it has to be configured in the csrn.scbr field. this allows the spi to au tomatically adapt the baud rate for each interfaced peripheral without reprogramming. 26.7.3.4 transfer delays figure 26-7 on page 664 shows a chip select transfer change and consecutive transfers on the same chip select. three delays can be configured to modify the transfer waveforms: ? the delay between chip selects, programmable only once for all the chip selects by writing to the delay between chip selects field in the mr register (mr. dlybcs). allows insertion of a delay between release of one chip select and before assertion of a new one. ? the delay before spck, independently programmable for each chip select by writing the delay before spck field in the csrn register s (csrn.dlybs). allows the start of spck to be delayed after the chip select has been asserted. ? the delay between consecutive transfers, independently programmable for each chip select by writing the delay between consecutive transfers field in the csrn registers (csrn.dlybct). allows insertion of a delay be tween two transfers occurring on the same chip select these delays allow the spi to be adapted to the interfaced peripherals and their speed and bus release time. figure 26-7. programmable delays dlybcs dlybs dlybct dlybct chip select 1 chip select 2 spck
665 32117b?avr-03/11 at32uc3c 26.7.3.5 peripheral selection the serial peripherals are selected through the assertion of the npcs0 to npcs3 signals. by default, all the npcs signals are high before and after each transfer. the peripheral selection can be performed in two different ways: ? fixed peripheral select: spi exchanges data with only one peripheral ? variable peripheral select: data can be exchanged with more than one peripheral fixed peripheral select is activated by writing a ze ro to the peripheral select bit in mr (mr.ps). in this case, the current peripheral is defined by the mr.pcs field and the tdr.pcs field has no effect. variable peripheral select is activated by writing a one to the mr.ps bit . the tdr.pcs field is used to select the current peripheral. this means that the peripheral selection can be defined for each new data. the fixed peripheral selection allows buffer transfers with a single peripheral. using the periph- eral dma controller is an optimal means, as the size of the data transfer between the memory and the spi is either 4 bits or 16 bits. however, changing the peripheral selection requires the mode register to be reprogrammed. the variable peripheral selection allows buffer transfers with multiple peripherals without repro- gramming the mr register. data written to tdr is 32-bits wide and defines the real data to be transmitted and the peripheral it is destined to. using the peripheral dma controller in this mode requires 32-bit wide buffers, with the data in the lsbs and the pcs and lastxfer fields in the msbs, however the spi still controls the number of bits (8 to16) to be transferr ed through miso and mosi lines with the csrn registers. this is not the optimal means in term of memory size for the buffers, but it provides a very effective means to exchange data with several peripherals without any intervention of the processor. 26.7.3.6 peripheral chip select decoding the user can configure the spi to operate with up to 15 peripherals by decoding the four chip select lines, npcs0 to npcs3 with an external logic. this can be enabled by writing a one to the chip select decode bit in the mr register (mr.pcsdec). when operating without decoding, the spi makes sure that in any case only one chip select line is activated, i.e. driven low at a time. if two bits are defined low in a pcs field, only the lowest numbered chip select is driven low. when operating with decoding, the spi directly outputs the value defined by the pcs field of either the mr register or the tdr register (depending on ps). as the spi sets a default value of 0xf on the chip select lines (i.e. all chip select lines at one) when not processing any transfer, only 15 peripherals can be decoded. the spi has only four chip select registers, not 15. as a result, when decoding is activated, each chip select defines the characteristics of up to four peripherals. as an example, the crs0 register defines the characteristics of the exter nally decoded peripherals 0 to 3, corresponding to the pcs values 0x0 to 0x3. thus, the user has to make sure to connect compatible peripherals on the decoded chip select lines 0 to 3, 4 to 7, 8 to 11 and 12 to 14. 26.7.3.7 peripheral deselection when operating normally, as soon as the transfer of the last data written in tdr is completed, the npcs lines all rise. this might lead to runtime error if the processor is too long in responding
666 32117b?avr-03/11 at32uc3c to an interrupt, and thus might lead to difficulties for interfacing with some serial peripherals requiring the chip select li ne to remain active during a full set of transfers. to facilitate interfacing with such devices, the csrn registers can be configur ed with the chip select active after transfer bit written to one (csrn.csaat) . this allows the chip select lines to remain in their current state (low = active) until transfer to another peripheral is required. when the csrn.csaat bit is written to qero, the npcs does not rise in all cases between two transfers on the same peripheral. during a transfe r on a chip select, the sr.tdre bit rises as soon as the content of the tdr is transferred into the internal shifter. when this bit is detected the tdr can be reloaded. if this reload occurs before the end of the current transfer and if the next transfer is performed on the same chip select as the current transfer, the chip select is not de-asserted between the two transfers. this migh t lead to difficulties fo r interfacing with some serial peripherals requiring the chip select to be de-asserted after each transfer. to facilitate interfacing with such devices, the csrn register s can be configured with the chip select not active after transfer bit (csrn.csnaat) written to one. this allows to de-assert systematically the chip select lines during a time dlybcs. (the value of th e csrn.csnaat bit is taken into account only if the csrn.csaat bit is written to zero for the same chip select). figure 26-8 on page 667 shows different peripheral deselection cases and the effect of the csrn.csaat and csrn.csnaat bits. 26.7.3.8 fifo management a fifo has been implemented in reception fifo (both in master and in slave mode), in order to be able to store up to 4 characters without causing an overrun error. if an attempt is made to store a fifth character, an overrun error rises. if such an event occurs, the fifo must be flushed. there are two ways to flush the fifo: ? by performing four read accesses of the rdr (the data read must be ignored) ? by writing a one to the flush fifo command bit in the cr register (cr.flushfifo). after that, the spi is able to receive new data.
667 32117b?avr-03/11 at32uc3c figure 26-8. peripheral deselection figure 26-8 on page 667 shows different peripheral deselection cases and the effect of the csrn.csaat and csrn.csnaat bits. 26.7.3.9 mode fault detection the spi is capable of detecting a mode fault when it is configured in master mode and npcs0, mosi, miso, and spck are configured as open dr ain through the i/o controller with either internal or external pullup resistors. if t he i/o controller does not have open-drain capability, mode fault detection must be disabled by writing a one to the mode fault detection bit in the mr a npcs[0..3] write tdr tdre npcs[0..3] write tdr tdre npcs[0..3] write tdr tdre dlybcs pcs = a dlybcs dlybct a pcs = b b dlybcs pcs = a dlybcs dlybct a pcs = b b dlybcs dlybct pcs=a a dlybcs dlybct a pcs = a a a dlybct aa csaat = 0 and csnaat = 0 dlybct aa csaat = 1 and csnaat= 0 / 1 a dlybcs pcs = a dlybct aa csaat = 0 and csnaat = 1 npcs[0..3] write tdr tdre pcs = a dlybct aa csaat = 0 and csnaat = 0
668 32117b?avr-03/11 at32uc3c register (mr.modfdis). in systems with open-drain i/o lines, a mode fault is detected when a low level is driven by an external master on the npcs0/nss signal. when a mode fault is detected, the mode fault error bit in the sr (sr.modf) is set until the sr is read and the spi is automatically disabled until re-enabled by writing a one to the spi enable bit in the cr register (cr.spien). by default, the mode fault detection circuitry is enabled. the user can disable mode fault detec- tion by writing a one to the mode fault dete ction bit in the mr re gister (mr.modfdis). 26.7.4 spi slave mode when operating in slave mode, the spi processes data bits on the clock provided on the spi clock pin (spck). the spi waits for nss to go active before receiving the serial clock from an external master. when nss falls, the clock is validated on the serializer, which processes the number of bits defined by the bits per transfer field of the chip select register 0 (csr0.bits). these bits are processed following a phase and a polarity defined respectively by the csr0.ncpha and csr0.cpol bits. note that the bits, cpol, and ncp ha bits of the other chip select registers have no effect when the spi is configured in slave mode. the bits are shifted out on the miso line and sampled on the mosi line. when all the bits are processed, the received data is transferred in the receive data register and the sr.rdrf bit rises. if the rdr register has not been read before new data is received, the sr.ovres bit is set. data is loaded in rdr even if this flag is set. th e user has to read the sr register to clear the sr.ovres bit. when a transfer starts, the data shifted out is the data present in the shift register. if no data has been written in the tdr register, the last data received is transferred. if no data has been received since the last reset, all bits are transmi tted low, as the shift register resets to zero. when a first data is written in tdr, it is trans ferred immediately in the shift register and the sr.tdre bit rises. if new data is written, it rema ins in tdr until a transfer occurs, i.e. nss falls and there is a valid clock on the spck pin. w hen the transfer occurs, the last data written in tdr is transferred in the shift register and the sr.tdre bit rises. this enables frequent updates of critical variables with single transfers. then, a new data is loaded in the shift register from the tdr. in case no character is ready to be transmitted, i.e. no character has been written in tdr since the last load from tdr to the shift register, the shift register is not modified and the last received character is retransmitted. in this case the underrun error status bit is set in sr (sr.undes). figure 26-9 on page 669 shows a block diagram of the spi when operating in slave mode.
669 32117b?avr-03/11 at32uc3c figure 26-9. slave mode functional block diagram shift register spck spiens lsb msb nss mosi spi clock tdre tdr td rdrf ovres csr0 cpol ncpha bits spien spidis miso undes rdr rd 4 - character fifo 0 1 rxfifoen
670 32117b?avr-03/11 at32uc3c 26.8 user interface note: 1. the reset values are device specific. please refer to the module configuration section at the end of this chapter. table 26-3. spi register memory map offset register register name access reset 0x00 control register cr write-only 0x00000000 0x04 mode register mr read/write 0x00000000 0x08 receive data register rdr read-only 0x00000000 0x0c transmit data register tdr write-only 0x00000000 0x10 status register sr read-only 0x00000000 0x14 interrupt enable register ier write-only 0x00000000 0x18 interrupt disable register idr write-only 0x00000000 0x1c interrupt mask register imr read-only 0x00000000 0x30 chip select register 0 csr0 read/write 0x00000000 0x34 chip select register 1 csr1 read/write 0x00000000 0x38 chip select register 2 csr2 read/write 0x00000000 0x3c chip select register 3 csr3 read/write 0x00000000 0x e4 write protection control register wpcr read/write 0x00000000 0xe8 write protection status register wpsr read-only 0x00000000 0xf8 features register features read-only - (1) 0xfc version register version read-only - (1)
671 32117b?avr-03/11 at32uc3c 26.8.1 control register name: cr access type: write-only offset: 0x00 reset value: 0x00000000 ? lastxfer: last transfer 1: the current npcs will be deasserted after the character wr itten in td has been transferred. when csrn.csaat is one, this allows to close the communication with the current serial peri pheral by raising the corresponding npcs line as soon as td transfer has completed. 0: writing a zero to this bit has no effect. ? flushfifo: flush fifo command 1: if the fifo mode is enabled (mr.fifoen written to one) and if an overrun error has been detected, this command allows to empty the fifo. 0: writing a zero to this bit has no effect. ? swrst: spi software reset 1: writing a one to this bit will reset the spi. a software-trigger ed hardware reset of the spi interface is performed. the spi is in slave mode after software reset. peripheral dma controller channels are not affected by software reset. 0: writing a zero to this bit has no effect. ? spidis: spi disable 1: writing a one to this bit will disable the spi. as soon as spi dis is written to one, the spi finishes its transfer, all pins are set in input mode and no data is received or transmitted. if a transfe r is in progress, the transfer is finished before the spi is disabled. if both spien and spidis are equal to one when the cr register is written, the spi is disabled. 0: writing a zero to this bit has no effect. ? spien: spi enable 1: writing a one to this bit will enable the spi to transfer and receive data. 0: writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 -------lastxfer 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------flushfifo 76543210 swrst - - - - - spidis spien
672 32117b?avr-03/11 at32uc3c 26.8.2 mode register name: mr access type: read/write offset: 0x04 reset value: 0x00000000 ? dlybcs: delay between chip selects this field defines the delay from npcs inactive to the activation of another npcs. the dlybcs time guarantees non- overlapping chip selects and solves bus contentions in case of peripherals having long data float times. if dlybcs is less than or equal to six, six clk_spi periods will be inserted by default. otherwise, the following equation determines the delay: ? pcs: peripheral chip select this field is only used if fixed peripheral select is active (ps = 0). if pcsdec = 0: pcs = xxx0npcs[3:0] = 1110 pcs = xx01npcs[3:0] = 1101 pcs = x011npcs[3:0] = 1011 pcs = 0111npcs[3:0] = 0111 pcs = 1111forbidden (no peripheral is selected) (x = don?t care) if pcsdec = 1: npcs[3:0] output signals = pcs. ? llb: local loopback enable 1: local loopback path enabled. llb controls the local loopback on the data serializer for testing in master mode only (miso is internally connected on mosi). 0: local loopback path disabled. ? rxfifoen: fifo in reception enable 1: the fifo is used in reception (f our characters can be stored in the spi). 31 30 29 28 27 26 25 24 dlybcs 23 22 21 20 19 18 17 16 ---- pcs 15 14 13 12 11 10 9 8 -------- 76543210 llb rxfifoen - modf dis - pcsdec ps mstr delay between chip selects dlybcs clkspi ---------------------- - =
673 32117b?avr-03/11 at32uc3c 0: the fifo is not used in reception (onl y one character can be stored in the spi). ? modfdis: mode fault detection 1: mode fault detection is disabled. if the i/o controller does not have o pen-drain capability, mode fault detection must be disabled for proper operation of the spi. 0: mode fault detection is enabled. ? pcsdec: chip select decode 0: the chip selects are directly connected to a peripheral device. 1: the four chip select lines are co nnected to a 4- to 16-bit decoder. when pcsdec equals one, up to 15 chip select signals can be generated with the four lines using an external 4- to 16-bit decoder. the csrn registers define the characteristics of the 15 chip selects according to the following rules: csr0 defines peripheral chip select signals 0 to 3. csr1 defines peripheral chip select signals 4 to 7. csr2 defines peripheral chip select signals 8 to 11. csr3 defines peripheral chip select signals 12 to 14. ? ps: peripheral select 1: variable peripheral select. 0: fixed peripheral select. ? mstr: master/slave mode 1: spi is in master mode. 0: spi is in slave mode.
674 32117b?avr-03/11 at32uc3c 26.8.3 receive data register name: rdr access type: read-only offset: 0x08 reset value: 0x00000000 ? rd: receive data data received by the spi interface is stored in this register right-justified. unused bits read zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 rd[15:8] 76543210 rd[7:0]
675 32117b?avr-03/11 at32uc3c 26.8.4 transmit data register name: tdr access type: write-only offset: 0x0c reset value: 0x00000000 ? lastxfer: last transfer 1: the current npcs will be deasserted after the character wr itten in td has been transferred. when csrn.csaat is one, this allows to close the communication with the current serial peri pheral by raising the corresponding npcs line as soon as td transfer has completed. 0: writing a zero to this bit has no effect. this field is only used if variable peripheral select is active (mr.ps = 1). ? pcs: peripheral chip select if pcsdec = 0: pcs = xxx0npcs[3:0] = 1110 pcs = xx01npcs[3:0] = 1101 pcs = x011npcs[3:0] = 1011 pcs = 0111npcs[3:0] = 0111 pcs = 1111forbidden (no peripheral is selected) (x = don?t care) if pcsdec = 1: npcs[3:0] output signals = pcs this field is only used if variable peripheral select is active (mr.ps = 1). ? td: transmit data data to be transmitted by the spi interface is stored in this re gister. information to be transmitted must be written to the td r register in a right-justified format. 31 30 29 28 27 26 25 24 -------lastxfer 23 22 21 20 19 18 17 16 ---- pcs 15 14 13 12 11 10 9 8 td[15:8] 76543210 td[7:0]
676 32117b?avr-03/11 at32uc3c 26.8.5 status register name: sr access type: read-only offset: 0x10 reset value: 0x00000000 ? spiens: spi enable status 1: this bit is set when the spi is enabled. 0: this bit is cleared when the spi is disabled. ? undes: underrun error st atus (slave mode only) 1: this bit is set when a transfer begins whereas no data has been loaded in the tdr register. 0: this bit is cleared when the sr register is read. ? txempty: transmission registers empty 1: this bit is set when tdr and internal shifter are empty. if a transfer delay has been defined, txempty is set after the completion of such delay. 0: this bit is cleared as soon as data is written in tdr. ? nssr: nss rising 1: a rising edge occurred on nss pin since last read. 0: this bit is cleared when the sr register is read. ? ovres: overrun error status 1: this bit is set when an overrun has occurred. an overrun occu rs when rdr is loaded at least twice from the serializer since the last read of the rdr. 0: this bit is cleared when the sr register is read. ? modf: mode fault error 1: this bit is set when a mode fault occurred. 0: this bit is cleared when the sr register is read. ? tdre: transmit data register empty 1: this bit is set when the last data written in the tdr register has been transferred to the serializer. 0: this bit is cleared when data has been written to tdr and not yet transferred to the serializer. tdre equals zero when the spi is disabled or at re set. the spi enable command sets this bit to one. ? rdrf: receive data register full 1: data has been received and the received data has been transferr ed from the serializer to rdr since the last read of rdr. 0: no data has been received since the last read of rdr 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------spiens 15 14 13 12 11 10 9 8 - - - - - undes txempty nssr 76543210 - - - - ovres modf tdre rdrf
677 32117b?avr-03/11 at32uc3c 26.8.6 interrupt enable register name: ier access type: write-only offset: 0x14 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - undes txempty nssr 76543210 - - - - ovres modf tdre rdrf
678 32117b?avr-03/11 at32uc3c 26.8.7 interrupt disable register name: idr access type: write-only offset: 0x18 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - undes txempty nssr 76543210 - - - - ovres modf tdre rdrf
679 32117b?avr-03/11 at32uc3c 26.8.8 interrupt mask register name: imr access type: read-only offset: 0x1c reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - undes txempty nssr 76543210 - - - - ovres modf tdre rdrf
680 32117b?avr-03/11 at32uc3c 26.8.9 chip select register 0 name: csr0 access type: read/write offset: 0x30 reset value: 0x00000000 ? dlybct: delay between consecutive transfers this field defines the delay between two consecutive transfers wi th the same peripheral without removing the chip select. the delay is always inserted after each transfer and before removing the chip select if needed. when dlybct equals zero, no delay between consecutive transfers is inserted and the clock keeps its duty cycle over the character transfers. otherwise, the following equation determines the delay: ? dlybs: delay before spck this field defines the delay from npcs valid to the first valid spck transition. when dlybs equals zero, the npcs valid to spck transition is 1/2 the spck clock period. otherwise, the following equat ions determine the delay: ? scbr: serial clock baud rate in master mode, the spi interface uses a modulus counter to de rive the spck baud rate from the clk_spi. the baud rate is selected by writing a value from 1 to 255 in the scbr field. the following equations determine the spck baud rate: writing the scbr field to zero is forbidden. triggering a transfer while scbr is zero can lead to unpredictable results. at reset, scbr is zero and the user has to write it to a valid value before performing the first transfer. if a clock divider (scbrn) field is set to one and the other scbr fields differ from one, access on csn is correct but no corre ct access will be possible on other cs. 31 30 29 28 27 26 25 24 dlybct 23 22 21 20 19 18 17 16 dlybs 15 14 13 12 11 10 9 8 scbr 76543210 bits csaat csnaat ncpha cpol delay between consecutive transfers 32 dlybct clkspi ------------------------------------ = delay before spck dlybs clkspi --------------------- = spck baudrate clkspi scbr --------------------- =
681 32117b?avr-03/11 at32uc3c ? bits: bits per transfer the bits field determines the number of data bits transferred. reserved values should not be used. ? csaat: chip select active after transfer 1: the peripheral chip select does not ri se after the last transfer is achieved. it remains active until a new transfer is requ ested on a different chip select. 0: the peripheral chip select line rises as soon as the last transfer is achieved. ? csnaat: chip select not active afte r transfer (ignored if csaat = 1) 0: the peripheral chip select does not rise between two transfers if the tdr is reloaded before the end of the first transfer a nd if the two transfers occur on the same chip select. 1: the peripheral chip select rises system atically between each transfe r performed on the same slave for a minimal duration of: (if dlybct field is different from 0) (if dlybct field equals 0) ? ncpha: clock phase 1: data is captured after the leading (inactive-to-active) e dge of spck and changed on the trailing (active-to-inactive) edge o f spck. 0: data is changed on the leading (inactive-to-active) edge of spck and captured after the trailing (active-to-inactive) edge o f spck. ncpha determines which edge of spck causes data to change and which edge causes data to be captured. ncpha is used with cpol to produce the requir ed clock/data relationship between master and slave devices. ?cpol: clock polarity 1: the inactive state value of spck is logic level one. 0: the inactive state value of spck is logic level zero. bits bits per transfer 0000 8 0001 9 0010 10 0011 11 0100 12 0101 13 0110 14 0111 15 1000 16 1001 4 1010 5 1011 6 1100 7 1101 reserved 1110 reserved 1111 reserved dlybcs clkspi ---------------------- - dlybcs 1 + clkspi -------------------------------- -
682 32117b?avr-03/11 at32uc3c cpol is used to determine the inactive state value of the seri al clock (spck). it is used wit h ncpha to produce the required clock/data relationship between master and slave devices.
683 32117b?avr-03/11 at32uc3c 26.8.10 chip select register 1 name: csr1 access type: read/write offset: 0x34 reset value: 0x00000000 ? dlybct: delay between consecutive transfers this field defines the delay between two consecutive transfers wi th the same peripheral without removing the chip select. the delay is always inserted after each transfer and before removing the chip select if needed. when dlybct equals zero, no delay between consecutive transfers is inserted and the clock keeps its duty cycle over the character transfers. otherwise, the following equation determines the delay: ? dlybs: delay before spck this field defines the delay from npcs valid to the first valid spck transition. when dlybs equals zero, the npcs valid to spck transition is 1/2 the spck clock period. otherwise, the following equat ions determine the delay: ? scbr: serial clock baud rate in master mode, the spi interface uses a modulus counter to de rive the spck baud rate from the clk_spi. the baud rate is selected by writing a value from 1 to 255 in the scbr field. the following equations determine the spck baud rate: writing the scbr field to zero is forbidden. triggering a transfer while scbr is zero can lead to unpredictable results. at reset, scbr is zero and the user has to write it to a valid value before performing the first transfer. if a clock divider (scbrn) field is set to one and the other scbr fields differ from one, access on csn is correct but no corre ct access will be possible on other cs. 31 30 29 28 27 26 25 24 dlybct 23 22 21 20 19 18 17 16 dlybs 15 14 13 12 11 10 9 8 scbr 76543210 bits csaat csnaat ncpha cpol delay between consecutive transfers 32 dlybct clkspi ------------------------------------ = delay before spck dlybs clkspi --------------------- = spck baudrate clkspi scbr --------------------- =
684 32117b?avr-03/11 at32uc3c ? bits: bits per transfer the bits field determines the number of data bits transferred. reserved values should not be used. ? csaat: chip select active after transfer 1: the peripheral chip select does not ri se after the last transfer is achieved. it remains active until a new transfer is requ ested on a different chip select. 0: the peripheral chip select line rises as soon as the last transfer is achieved. ? csnaat: chip select not active afte r transfer (ignored if csaat = 1) 0: the peripheral chip select does not rise between two transfers if the tdr is reloaded before the end of the first transfer a nd if the two transfers occur on the same chip select. 1: the peripheral chip select rises system atically between each transfe r performed on the same slave for a minimal duration of: (if dlybct field is different from 0) (if dlybct field equals 0) ? ncpha: clock phase 1: data is captured after the leading (inactive-to-active) e dge of spck and changed on the trailing (active-to-inactive) edge o f spck. 0: data is changed on the leading (inactive-to-active) edge of spck and captured after the trailing (active-to-inactive) edge o f spck. ncpha determines which edge of spck causes data to change and which edge causes data to be captured. ncpha is used with cpol to produce the requir ed clock/data relationship between master and slave devices. ?cpol: clock polarity 1: the inactive state value of spck is logic level one. 0: the inactive state value of spck is logic level zero. bits bits per transfer 0000 8 0001 9 0010 10 0011 11 0100 12 0101 13 0110 14 0111 15 1000 16 1001 4 1010 5 1011 6 1100 7 1101 reserved 1110 reserved 1111 reserved dlybcs clkspi ---------------------- - dlybcs 1 + clkspi -------------------------------- -
685 32117b?avr-03/11 at32uc3c cpol is used to determine the inactive state value of the seri al clock (spck). it is used wit h ncpha to produce the required clock/data relationship between master and slave devices.
686 32117b?avr-03/11 at32uc3c 26.8.11 chip select register 2 name: csr2 access type: read/write offset: 0x38 reset value: 0x00000000 ? dlybct: delay between consecutive transfers this field defines the delay between two consecutive transfers wi th the same peripheral without removing the chip select. the delay is always inserted after each transfer and before removing the chip select if needed. when dlybct equals zero, no delay between consecutive transfers is inserted and the clock keeps its duty cycle over the character transfers. otherwise, the following equation determines the delay: ? dlybs: delay before spck this field defines the delay from npcs valid to the first valid spck transition. when dlybs equals zero, the npcs valid to spck transition is 1/2 the spck clock period. otherwise, the following equat ions determine the delay: ? scbr: serial clock baud rate in master mode, the spi interface uses a modulus counter to de rive the spck baud rate from the clk_spi. the baud rate is selected by writing a value from 1 to 255 in the scbr field. the following equations determine the spck baud rate: writing the scbr field to zero is forbidden. triggering a transfer while scbr is zero can lead to unpredictable results. at reset, scbr is zero and the user has to write it to a valid value before performing the first transfer. if a clock divider (scbrn) field is set to one and the other scbr fields differ from one, access on csn is correct but no corre ct access will be possible on other cs. 31 30 29 28 27 26 25 24 dlybct 23 22 21 20 19 18 17 16 dlybs 15 14 13 12 11 10 9 8 scbr 76543210 bits csaat csnaat ncpha cpol delay between consecutive transfers 32 dlybct clkspi ------------------------------------ = delay before spck dlybs clkspi --------------------- = spck baudrate clkspi scbr --------------------- =
687 32117b?avr-03/11 at32uc3c ? bits: bits per transfer the bits field determines the number of data bits transferred. reserved values should not be used. ? csaat: chip select active after transfer 1: the peripheral chip select does not ri se after the last transfer is achieved. it remains active until a new transfer is requ ested on a different chip select. 0: the peripheral chip select line rises as soon as the last transfer is achieved. ? csnaat: chip select not active afte r transfer (ignored if csaat = 1) 0: the peripheral chip select does not rise between two transfers if the tdr is reloaded before the end of the first transfer a nd if the two transfers occur on the same chip select. 1: the peripheral chip select rises system atically between each transfe r performed on the same slave for a minimal duration of: (if dlybct field is different from 0) (if dlybct field equals 0) ? ncpha: clock phase 1: data is captured after the leading (inactive-to-active) e dge of spck and changed on the trailing (active-to-inactive) edge o f spck. 0: data is changed on the leading (inactive-to-active) edge of spck and captured after the trailing (active-to-inactive) edge o f spck. ncpha determines which edge of spck causes data to change and which edge causes data to be captured. ncpha is used with cpol to produce the requir ed clock/data relationship between master and slave devices. ?cpol: clock polarity 1: the inactive state value of spck is logic level one. 0: the inactive state value of spck is logic level zero. bits bits per transfer 0000 8 0001 9 0010 10 0011 11 0100 12 0101 13 0110 14 0111 15 1000 16 1001 4 1010 5 1011 6 1100 7 1101 reserved 1110 reserved 1111 reserved dlybcs clkspi ---------------------- - dlybcs 1 + clkspi -------------------------------- -
688 32117b?avr-03/11 at32uc3c cpol is used to determine the inactive state value of the seri al clock (spck). it is used wit h ncpha to produce the required clock/data relationship between master and slave devices.
689 32117b?avr-03/11 at32uc3c 26.8.12 chip select register 3 name: csr3 access type: read/write offset: 0x3c reset value: 0x00000000 ? dlybct: delay between consecutive transfers this field defines the delay between two consecutive transfers wi th the same peripheral without removing the chip select. the delay is always inserted after each transfer and before removing the chip select if needed. when dlybct equals zero, no delay between consecutive transfers is inserted and the clock keeps its duty cycle over the character transfers. otherwise, the following equation determines the delay: ? dlybs: delay before spck this field defines the delay from npcs valid to the first valid spck transition. when dlybs equals zero, the npcs valid to spck transition is 1/2 the spck clock period. otherwise, the following equat ions determine the delay: ? scbr: serial clock baud rate in master mode, the spi interface uses a modulus counter to de rive the spck baud rate from the clk_spi. the baud rate is selected by writing a value from 1 to 255 in the scbr field. the following equations determine the spck baud rate: writing the scbr field to zero is forbidden. triggering a transfer while scbr is zero can lead to unpredictable results. at reset, scbr is zero and the user has to write it to a valid value before performing the first transfer. if a clock divider (scbrn) field is set to one and the other scbr fields differ from one, access on csn is correct but no corre ct access will be possible on other cs. 31 30 29 28 27 26 25 24 dlybct 23 22 21 20 19 18 17 16 dlybs 15 14 13 12 11 10 9 8 scbr 76543210 bits csaat csnaat ncpha cpol delay between consecutive transfers 32 dlybct clkspi ------------------------------------ = delay before spck dlybs clkspi --------------------- = spck baudrate clkspi scbr --------------------- =
690 32117b?avr-03/11 at32uc3c ? bits: bits per transfer the bits field determines the number of data bits transferred. reserved values should not be used. ? csaat: chip select active after transfer 1: the peripheral chip select does not ri se after the last transfer is achieved. it remains active until a new transfer is requ ested on a different chip select. 0: the peripheral chip select line rises as soon as the last transfer is achieved. ? csnaat: chip select not active afte r transfer (ignored if csaat = 1) 0: the peripheral chip select does not rise between two transfers if the tdr is reloaded before the end of the first transfer a nd if the two transfers occur on the same chip select. 1: the peripheral chip select rises system atically between each transfe r performed on the same slave for a minimal duration of: (if dlybct field is different from 0) (if dlybct field equals 0) ? ncpha: clock phase 1: data is captured after the leading (inactive-to-active) e dge of spck and changed on the trailing (active-to-inactive) edge o f spck. 0: data is changed on the leading (inactive-to-active) edge of spck and captured after the trailing (active-to-inactive) edge o f spck. ncpha determines which edge of spck causes data to change and which edge causes data to be captured. ncpha is used with cpol to produce the requir ed clock/data relationship between master and slave devices. ?cpol: clock polarity 1: the inactive state value of spck is logic level one. 0: the inactive state value of spck is logic level zero. bits bits per transfer 0000 8 0001 9 0010 10 0011 11 0100 12 0101 13 0110 14 0111 15 1000 16 1001 4 1010 5 1011 6 1100 7 1101 reserved 1110 reserved 1111 reserved dlybcs clkspi ---------------------- - dlybcs 1 + clkspi -------------------------------- -
691 32117b?avr-03/11 at32uc3c cpol is used to determine the inactive state value of the seri al clock (spck). it is used wit h ncpha to produce the required clock/data relationship between master and slave devices.
692 32117b?avr-03/11 at32uc3c 26.8.13 write protection control register register name: wpcr access type: read-write offset: 0xe4 reset value: 0x00000000 ? spiwpkey: spi write protection key password if a value is written in spiwpen, the value is taken into acc ount only if spiwpkey is written wit h ?spi? (spi written in ascii code, i.e. 0x535049 in hexadecimal). ? spiwpen: spi write protection enable 1: the write protection is enabled 0: the write protection is disabled 31 30 29 28 27 26 25 24 spiwpkey[23:16] 23 22 21 20 19 18 17 16 spiwpkey[15:8] 15 14 13 12 11 10 9 8 spiwpkey[7:0] 76543210 -------spiwpen
693 32117b?avr-03/11 at32uc3c 26.8.14 write protection status register register name: wpsr access type: read-only offset: 0xe8 reset value: 0x00000000 ? spiwpvsrc: spi write protection violation source this field indicates the peripheral bus offset of th e register concerned by the violation (mr or csrx) ? spiwpvs: spi write prot ection violation status 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 spiwpvsrc 76543210 - - - - - spiwpvs spiwpvs value violation type 1 the write protection has blocked a write access to a protected register (since the last read). 2 software reset has been performed while write protection was enabled (since the last read or since the last write acce ss on mr, ier, idr or csrx). 3 both write protection violation and software reset with write protection enabled have occurred since the last read. 4 write accesses have been detected on mr (while a chip select was active) or on csri (while the chip select ?i? was active) since the last read. 5 the write protection has blocked a write acce ss to a protected register and write accesses have been detected on mr (while a chip select was active) or on csri (while the chip select ?i? was active) since the last read. 6 software reset has been performed while write protection was enabled (since the last read or since the last write access on mr, ier, idr or csrx) and some write accesses have been detected on mr (while a chip select was active) or on csri (while the chip select ?i? was active) since the last read. 7 - the write protection has blocked a write access to a protected register. and - software reset has been performed while write protection was enabled. and - write accesses have been detected on mr (while a chip select was active) or on csri (while the chip select ?i? was active) since the last read.
694 32117b?avr-03/11 at32uc3c 26.8.15 features register register name: features access type: read-only offset: 0xf8 reset value: ? ? swimpl: spurious write protection implemented 0: spurious write protec tion is not implemented. 1: spurious write prot ection is implemented. ? fiforimpl: fifo in reception implemented 0: fifo in receptio n is not implemented. 1: fifo in recept ion is implemented. ? brpbhsb: bridge type is pb to hsb 0: bridge type is not pb to hsb. 1: bridge type is pb to hsb. ? csnaatimpl: csnaat features implemented 0: csnaat (chip select not active after transfer) features are not implemented. 1: csnaat features are implemented. ? extdec: external decoder true 0: external decoder capability is not implemented. 1: external decoder capability is implemented. ? lennconf: character length if not configurable if the character length is not configurable, th is field specifies the fixed character length. ? lenconf: character length configurable 0: the character length is not configurable. 1: the character length is configurable. ? phznconf: phase is zero if phase not configurable 0: if phase is not config urable, phase is non-zero. 1: if phase is not configurable, phase is zero. ? phconf: phase configurable 0: phase is not configurable. 1: phase is configurable. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - swimpl fiforimpl brpbhsb csnaatimpl extdec 15 14 13 12 11 10 9 8 lennconf lenconf 76543210 phznconf phconf ppnconf pconf ncs
695 32117b?avr-03/11 at32uc3c ? ppnconf: polarity positive if polarity not configurable 0: if polarity is not configurable, polarity is negative. 1: if polarity is not configurable, polarity is positive. ? pconf: polarity configurable 0: polarity is not configurable. 1: polarity is configurable. ? ncs: number of chip selects this field indicates the number of chip selects implemented.
696 32117b?avr-03/11 at32uc3c 26.8.16 version register register name: version access type: read-only offset: 0xfc reset value: ? ? mfn reserved. no functionality associated. ? version version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- mfn 15 14 13 12 11 10 9 8 version[11:8] 76543210 version[7:0]
697 32117b?avr-03/11 at32uc3c 26.9 module configuration the specific configuration for ea ch spi instance is listed in t he following tables. the module bus clocks listed here are connecte d to the system bus clocks. pleas e refer to the power manager chapter for details. table 26-4. spi clock name module name clock name description spi0 clk_spi0 peripheral bus clock from the pbc clock domain spi1 clk_spi1 peripheral bus clock from the pba clock domain table 26-5. register reset values register reset value features 0x001f0154 version 0x00000211
698 32117b?avr-03/11 at32uc3c 27. two-wire master interface (twim) rev: 1.1.0.1 27.1 features ? compatible with i 2 c standard ? multi-master support ? 100 and 400 kbit/sin transfer speed ? 7- and 10-bit and general call addressing ? compatible with smbus standard ? hardware packet error checking (crc) ge neration and verification with ack control ? smbus alert interface ? 25 ms clock low timeout delay ? 10 ms master cumulative clock low extend time ? 25 ms slave cumulative clock low extend time ? compatible with pmbus ? compatible with atmel two-wi re interface se rial memories ? dma interface for reducing cpu load ? arbitrary transfer lengths, including 0 data bytes ? optional clock stretching if transmit or receive buffers not ready for data transfer 27.2 overview the atmel two-wire interface master (twim) interconnects components on a unique two-wire bus, made up of one clock line and one data line with speeds of up to 400 kbit/s, based on a byte-oriented transfer format. it can be used with any atmel two-wire interface bus serial eeprom and i2c compatible device such as a r eal rime clock (rtc), dot matrix/graphic lcd controller and temperature sensor, to name a few. twim is always a bus master and can trans- fer sequential or single bytes. multiple master capability is supported. arbitration of the bus is performed internally and relinquishes the bus automatically if the bus arbitration is lost. a configurable baud rate generator permits the output data rate to be adapted to a wide range of core clock frequencies. table 27-1 on page 698 lists the compatibility le vel of the atmel two-wire interface in master mode and a full i2c compatible device. note: 1. start + b000000001 + ack + sr table 27-1. atmel twim compatib ility with i2c standard i2c standard atmel twim standard-mode (100 kbit/s) supported fast-mode (400 kbit/s) supported fast-mode plus (1 mbit/s) supported 7- or 10-bits slave addressing supported start byte (1) not supported repeated start (sr) condition supported ack and nack management supported slope control and input filtering (fast mode) supported clock stretching supported
699 32117b?avr-03/11 at32uc3c table 27-2 on page 699 lists the compatibility level of the atmel two-wire master interface and a full smbus compatible master. 27.3 list of abbreviations table 27-2. atmel twim compatibilit y with smbus standard smbus standard atmel twim bus timeouts supported address resolution protocol supported alert supported host functionality supported packet error checking supported table 27-3. abbreviations abbreviation description twi two-wire interface a acknowledge na non acknowledge pstop sstart sr repeated start sadr slave address adr any address except sadr r read wwrite
700 32117b?avr-03/11 at32uc3c 27.4 block diagram figure 27-1. block diagram 27.5 application block diagram2 figure 27-2. application block diagram 27.6 i/o lines description peripheral bus bridge two-wire interface i/o controller twck twd intc twi interrupt power manager clk_twim twalm twi master twd twck atmel twi serial eeprom i 2 c rtc i 2 c lcd controller i 2 c temp sensor slave 2slave 3slave 4 vdd rp rp rp: pull-up value as given by the i2c standard twalm slave 1 rp table 27-4. i/o lines description pin name pin description type twd two-wire serial data input/output twck two-wire serial clock input/output twalm smbus smbalert input/output
701 32117b?avr-03/11 at32uc3c 27.7 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 27.7.1 i/o lines twd and twck are bidirectional lines, connected to a positive supply voltage via a current source or pull-up resistor (see figure 27-4 on page 702 ). when the bus is free, both lines are high. the output stages of devices connected to the bus must have an open-drain or open-col- lector to perform the wired-and function. twalm is used to implement the optional smbus smbalert signal. the twalm, twd, and twck pins may be multip lexed with i/o controller lines. to enable the twim, the programmer must perform the following steps: ? program the i/o controller to: ? dedicate twd, twck and optionally twalm as peripheral lines. ? define twd, twck and optionally twalm as open-drain. 27.7.2 power management if the cpu enters a sleep mode th at disables clocks used by t he twim, the twim will stop func- tioning and resume operation after the system wakes up from sleep mode. 27.7.3 clocks the clock for the twim bus interface (clk_twim) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to dis- able the twim before disabling the clock, to avoid freezing the twim in an undefined state. 27.7.4 dma the twim dma handshake interface is connected to the peripheral dma controller. using the twim dma functionality requires the peripheral dma controller to be programmed after setting up the twim. 27.7.5 interrupts the twim interrupt request lines are connected to the interrupt controller. using the twim inter- rupts requires the interrupt controller to be programmed first. 27.7.6 debug operation when an external debugger forces the cpu into debug mode, the twim continues normal oper- ation. if the twim is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging.
702 32117b?avr-03/11 at32uc3c 27.8 functional description 27.8.1 transfer format the data put on the twd line must be 8 bits long. data is transferred msb first; each byte must be followed by an acknowledgement. the number of bytes per transfer is unlimited (see figure 27-4 on page 702 ). each transfer begins with a start condition and terminates with a stop condition (see figure 27-4 on page 702 ). ? a high-to-low transition on the twd line while twck is high defines the start condition. ? a low-to-high transition on the twd line while twck is high defines a stop condition. figure 27-3. start and stop conditions figure 27-4. transfer format 27.8.2 operation the twim has two modes of operation: ? master transmitter mode ? master receiver mode the master is the device which starts and stops a transfer and generates the twck clock. these modes are described in the following chapters. twd twck start stop twd twck start address r/w ack data ack data ack stop
703 32117b?avr-03/11 at32uc3c 27.8.2.1 clock generation the the clock waveform generator register (cwgr) is used to control the waveform of the twck clock. cwgr must be programmed so that the desired twi bus timings are generated. cwgr describes bus timings as a function of cycles of a prescaled clock. the clock prescaling can be selected through the exp field in cwgr. cwgr has the following fields: low: prescaled clock cycles in cl ock low count. used to time t low . and t buf . high: prescaled clock cycles in cl ock high count. used to time t high . stasto: prescaled clock cycles in cl ock high count. used to time t hd_sta , t su_sta , t su_sto . data: prescaled clock cycles for data setu p and hold count. used to time t hd_dat , t su_dat . exp: specifies the clo ck prescaler setting. note that the total clock low time generated is the sum of t hd_dat + t su_dat + t low . any slave or other bus master taking part in the transfer may extend the twck low period at any time. the twim hardware monitors the state of the tw ck line as required by the i2c specification. the clock generation counters are started when a high/low level is detected on the twck line, not when the twim hardware releases/drives the twck line. this means that the cwgr set- tings alone do not determine the twck frequency. the cwgr settings determine the clock low time and the clock high time, but the twck rise a nd fall times are determined by the external cir- cuitry (capacitive load, etc.). figure 27-5. bus timing diagram f prescaled f clkpb 2 exp 1 + ) () ------------------------- - = s t hd:sta t low t su:dat t high t hd:dat t low p t su:sto sr t su:sta t su:dat
704 32117b?avr-03/11 at32uc3c 27.8.2.2 setting up and performing a transfer operation of twim is mainly controlled by the control register (cr) and the command register (cmdr). the following list presents the ma in steps in a typical communication: 1. before any transfers can be performed, bus timings must be configured by program- ming the clock waveform generator register (cwgr). if operating in smbus mode, the smbus timing register (smbtr) register must also be configured. 2. if a dma controller is to be used for the transfers, it must be set up. 3. cmdr or ncmdr must be programmed with a value describing the transfer to be performed. the interrupt system can be set up to give interr upt request on specific events or error condi- tions, for example when the transfer is complete or if arbitration is lost. the controller will refuse to star t a new transfer while anak, dnak or arblst is set in the sta- tus register (sr). this is necessary to avoid a race when the software issues a continuation of the current transfer at the same time as one of these errors happen. also, if anak or dnak occur, a stop condition is sent automatically. the programmer will have to restart the transmis- sion by clearing the errors bit in sr after resolving the cause for the nack. after a data or address nack from the slave, a stop will be transmitted automatically. note that the valid bit in cmdr is not cleared in this case. if this transfer is to be discarded, the valid bit can be cleared manually allowing any command in ncmdr to be copied into cmdr. when a data or address nack is returned by the slave while the master is transmitting, it is pos- sible that new data has already been written to th e thr register. this data will be tran sferred out as the first data byte of the next transfer. if this behavior is to be avoided, the safest approach is to perform a software reset of the twim. 27.8.3 master transmitter mode a start condition is transmitted and master trans mitter mode is initiated when the bus is free and cmdr has been written with start=1 and read=0. start and sadr+w will then be transmitted. during the address acknowledge clock pulse (9th pulse), the master releases the data line (high), enabling the slave to pull it down in order to acknowledge the address. the master polls the data line during this clock pulse and sets the address not acknowledged bit (anak ) in the status register if no slave acknowledges the address. after the address phase, the following is repeated: while (nbytes>0) 1. wait until thr contains a valid data byte, stretching low period of twck. sr.txrdy indicates the state of thr. software or a dma controller must write the data byte to thr. 2. transmit this data byte 3. decrement nbytes 4. if (nbytes==0) and stop=1, transmit stop condition programming cmdr with start=stop=1 and nbyt es=0 will generate a transmission with no data bytes, ie start, sadr+w, stop. twi transfers require the slave to acknowle dge each received data byte. during the acknowl- edge clock pulse (9th pulse), the master releases the data line (high), enabling the slave to pull it down in order to generate the acknowledge. t he master polls the data line during this clock pulse and sets the data acknowledge bit (dnack) in the status register if the slave does not
705 32117b?avr-03/11 at32uc3c acknowledge the data byte. as with the other status bits, an interrupt can be generated if enabled in the interrupt enable register (twim_ier). txrdy is used as transmit ready for the pe ripheral dma controller transmit channel. the end of a command is marked by setting the sr.ccomp bit to one. see figure 27-6 on page 705 and figure 27-7 on page 705 . figure 27-6. master write with one data byte figure 27-7. master write with mu ltiple data bytes 27.8.4 master receiver mode a start condition is transmitted and master receiver mode is initiated when the bus is free and cmdr has been written with start=1 and read=1. start and sadr+r will then be trans- mitted. during the address acknowledge clock puls e (9th pulse), the master releases the data line (high), enabling the slave to pull it down in order to acknowledge the address. the master polls the data line during this clock pulse and sets the address not acknowledged bit (anak) in the status register if no slave acknowledges the address. after the address phase, the following is repeated: while (nbytes>0) 1. wait until rhr is empty, stretching low period of twck. sr.rxrdy indicates the state of rhr. software or a dma controller must read any data byte present in rhr. 2. release twck generating a clock that the slave uses to transmit a data byte. 3. place the received data byte in rhr, set rxrdy. 4. if nbytes=0, generate a nak after the data byte, otherwise generate an ack. 5. decrement nbytes twd sr.idle txrdy write thr (data) nbytes set to 1 stop sent automatically (ack received and nbytes=0) s dadr w a data a p twd sr.idle txrdy write thr (datan) nbytes set to n stop sent automatically (ack received and nbytes=0) sdadr wa datan a datan+5 aa datan+m p write thr (datan+1) write thr (datan+m) last data sent
706 32117b?avr-03/11 at32uc3c 6. if (nbytes==0) and stop=1, transmit stop condition. programming cmdr with start=stop=1 and nbyt es=0 will generate a transmission with no data bytes, ie start, dadr+r, stop the twi transfers require the master to a cknowledge each received data byte. during the acknowledge clock pulse (9th pulse), the slave releases the data line (high), enabling the mas- ter to pull it down in order to generate the acknowledge. all data bytes except the last are acknowledged by the master. not acknowledging the last byte informs the slave that the transfer is finished. rxrdy is used as receive ready for the peripheral dma controller receive channel. figure 27-8. master read with one data byte figure 27-9. master read with mu ltiple data bytes 27.8.5 using the peripheral dma controller the use of the peripheral dma controller signi ficantly reduces the cpu load. the programmer can set up ring buffers for the dma controller, containing data to transmit or free buffer space to place received data. to assure correct behavior, respect the following programming sequences: twd sr.idle rxrdy write start & stop bit nbytes set to 1 read rhr sdadr r a data np twd sr.idle rxrdy write start + stop bit nbytes set to m s dadr r a datan a datan+m-1 an datan+m p read rhr datan datan+1 read rhr datan+m-2 read rhr datan+m-1 read rhr datan+m send stop when nbytes=0
707 32117b?avr-03/11 at32uc3c 27.8.5.1 data transmit with the peripheral dma controller 1. initialize the transmit peripheral dma controller (memory pointers, size, etc.). 2. configure the twim (adr, nbytes, etc.). 3. start the transfer by setting the peripheral dma controller txten bit. 4. wait for the peripheral dma controller end tx flag. 5. disable the peripheral dma controller by se tting the peripheral dma controller txdis bit. 27.8.5.2 data receive with th e peripheral dma controller 1. initialize the receive peripheral dma controller (memory pointers, size, etc.). 2. configure the twim (adr, nbytes, etc.). 3. start the transfer by setting the peripheral dma controller rxten bit. 4. wait for the peripheral dma controller end rx flag. 5. disable the peripheral dma controller by setting the peripheral dma controller rxdis bit. 27.8.6 multi-master mode more than one master may access the bus at the same time without data corruption by using arbitration. arbitration starts as soon as two or more masters place information on the bus at the same time, and stops (arbitration is lost) for the master that intends to send a logical one while the other master sends a logical zero. as soon as arbitration is lost by a master, it st ops sending data and listens to the bus in order to detect a stop. the sr.arblst flag will be set. when the stop is detected, the master who lost arbitration may reinitiate the data transfer. arbitration is illustrated in figure 27-11 on page 708 . if the user starts a transfer and if the bus is busy, twim automatically waits for a stop condition on the bus before initiating the transfer (see figure 27-10 on page 707 ). note: the state of the bus (busy or free) is not indicated in the user interface. figure 27-10. programmer sends data while the bus is busy twck twd data sent by a master stop sent by the master start sent by the twi data sent by the twi bus is busy bus is free a transfer is programmed (dadr + w + start + write thr) transfer is initiated twi data transfer transfer is kept bus is considered as free
708 32117b?avr-03/11 at32uc3c figure 27-11. arbitration cases 27.8.7 combined transfers cmdr and ncmdr may be used to generate longer sequences of connected transfers, since generation of start and/or stop conditions is programmable on a per-command basis. programming ncmdr with start=1 when the previous transfer was programmed with stop=0 will cause a repeated start on the bus. the ability to generate such connected transfers allows arbitrary transfer lengths, since it is legal to program cmdr with both start=0 and stop=0. if this is done in master receiver mode, the cmdr.acklast bit must also be controlled. as for single data transfers, the txrdy and rxrd y bits in the status register indicates when data to transmit can be written to the thr, or when received data can be read from rhr. trans- fer of data to thr and from rhr can also be done automatically by dma, see ?using the peripheral dma controller? on page 706 27.8.7.1 write followed by write consider the fo llowing transfer: start, dadr+w, data+a, data+a, repstart, dadr+w, data+a, data+a, stop. to generate this transfer: 1. program cmdr with start=1, stop=0, dadr, nbytes=2 and read=0. 2. program ncmdr with start=1, st op=1, dadr, nbytes=2 and read=0. 3. wait until sr.txrdy==1, then write first data byte to transfer to thr. 4. wait until sr.txrdy==1, then write second data byte to transfer to thr. twck bus is busy bus is free a transfer is programmed (dadr + w + start + write thr) transfer is initiated twi data transfer transfer is kept bus is considered as free data from a master data from twi s 0 s 0 0 1 1 1 arblst s 0 s 0 0 1 1 1 twd s 0 0 1 1 1 1 1 arbitration is lost twi stops sending data p s 0 1 p 0 1 1 1 1 data from the master data from the twi arbitration is lost the master stops sending data transfer is stopped transfer is programmed again (dadr + w + start + write thr) twck twd
709 32117b?avr-03/11 at32uc3c 5. wait until sr.txrdy==1, then write third data byte to transfer to thr. 6. wait until sr.txrdy==1, then write fourth data byte to transfer to thr. 27.8.7.2 read followed by read consider the fo llowing transfer: start, dadr+r, data+a, data+na, repstart, dadr+r, data+a, data+na, stop. to generate this transfer: 1. program cmdr with start=1, stop=0, dadr, nbytes=2 and read=1. 2. program ncmdr with start=1, st op=1, dadr, nbytes=2 and read=1. 3. wait until sr.rxrdy==1, then read first data byte received from rhr. 4. wait until sr.rxrdy==1, then read second data byte received from rhr. 5. wait until sr.rxrdy==1, then read third data byte received from rhr. 6. wait until sr.rxrdy==1, then read fourth data byte received from rhr. if combining several tr ansfers, without any stop or repeated start between them, remem- ber to set the acklast bit in cmdr to keep from ending each of the partial transfers with a nack. 27.8.7.3 write followed by read consider the fo llowing transfer: start, dadr+w, data+a, data+a, repstart, dadr+r, data+a, data+na, stop. figure 27-12. combining a write and read transfer to generate this transfer: 1. program cmdr with start=1, stop=0, dadr, nbytes=2 and read=0. 2. program ncmdr with start=1, st op=1, dadr, nbytes=2 and read=1. 3. wait until sr.txrdy==1, then write first data byte to transfer to thr. 4. wait until sr.txrdy==1, then write second data byte to transfer to thr. 5. wait until sr.rxrdy==1, then read first data byte received from rhr. 6. wait until sr.rxrdy==1, then read second data byte received from rhr. 27.8.7.4 read followed by write consider the fo llowing transfer: start, dadr+r, data+a, data+na, repstart, dadr+w, data+a, data+a, stop. twd sr.idle txrdy sdadr wa data0 a data1 na sr dadr r a data2 a data3 a p data0 data1 thr rxrdy 1 rhr data3 data2
710 32117b?avr-03/11 at32uc3c figure 27-13. combining a read and write transfer to generate this transfer: 1. program cmdr with start=1, stop=0, dadr, nbytes=2 and read=1. 2. program ncmdr with start=1, st op=1, dadr, nbytes=2 and read=0. 3. wait until sr.rxrdy==1, then read first data byte received from rhr. 4. wait until sr.rxrdy==1, then read second data byte received from rhr. 5. wait until sr.txrdy==1, then write first data byte to transfer to thr. 6. wait until sr.txrdy==1, then write second data byte to transfer to thr. 27.8.8 ten bit addressing setting cmdr.tenbit enables 10-bit addressing in hardware. performing transfers with 10-bit addressing is similar to transfers with 7-bit addresses, except that bits 10:7 of cmdr.adr must be set appropriately. in figure 27-14 on page 710 and figure 27-15 on page 711 , the grey boxes represent signals driven by the master, the white boxes are driven by the slave. 27.8.8.1 master transmitter to perform a master transmitter transfer, 1. program cmdr with tenbit=1, repsame=0, read=0, start=1, stop=1 and the desired address and nbytes value. figure 27-14. a write transfer with 10-bit addressing 27.8.8.2 master receiver when using master receiver mode with 10-bit addressing, cm dr.repsame must also be con- trolled. cmdr.repsame must be written to one when the address phase of the transfer should consist of only 1 address byte (the 11110xx byte) and not 2 address bytes. the i2c standard specifies that such addressing is required wh en addressing a slave for reads using 10-bit addressing. to perform a master receiver transfer, twd sr.idle txrdy s sadr r a data0 a data1 sr dadr w a data2 a data3 na p data2 thr rxrdy rhr data3 data0 a 1 2 data3 read twi_rhr s slave address 1st 7 bits p a data rw a1 a2 slave address 2nd byte aa data 11110xx0
711 32117b?avr-03/11 at32uc3c 1. program cmdr with tenbit=1, repsam e=0, read=0, start=1, stop=0, nbytes=0 and the desired address. 2. program ncmdr with tenbit=1, repsame=1, read=1, start=1, stop=1 and the desired address and nbytes value. figure 27-15. a read transfer with 10-bit addressing 27.8.9 smbus mode smbus mode is enabled and disabled by the smen and smdis bits in cr. smbus mode oper- ation is similar to i2c operation with the following exceptions: ? only 7-bit addressing can be used. ? the smbus standard describes a set of timeout values to ensure progress and throughput on the bus. these timeout values must be programmed into smbtr. ? transmissions can optionally include a crc byte, called packet error check (pec). ? a dedicated bus line, smbalert, allows a slave to get a master?s attention. ? a set of addresses have been reserved for protocol handling, such as alert response address (ara) and host header (hh) address. 27.8.9.1 packet error checking each smbus transfer can optionally end with a crc byte, called the pec byte. writing cmdr.pecen to one enables automatic pec handling in the current transfer. transfers with and without pec can freely be intermixed in the same system, since some slaves may not sup- port pec. the pec lfsr is always updated on every bit transmitted or received, so that pec handling on combined transfers will be correct. in master transmitter mode, the master calculates a pec value and transmits it to the slave after all data bytes have been transm itted. upon reception of this pec byte, the slave will compare it to the pec value it has computed itself. if the values match, the data was received correctly, and the slave will return an ack to th e master. if the pec values differ, data was corrupted, and the slave will return a nack value. the dnak bit in sr reflects the state of the last received ack/nack value. some slaves may not be able to check the received pec in time to return a nack if an error occurred. in this case, the slave should always retu rn an ack after the pec byte, and some other mechanism must be implemented to verify that the transmission was received correctly. in master receiver mode, the slave calculates a pec value and transmits it to the master after all data bytes have been transmitted. upon reception of this pec by te, the master will compare it to the pec value it has computed itself. if the values match, the data was received correctly. if the pec values differ, data was corrupted, and the pecerr bit in sr is set. in master receiver mode, the pec byte is always followed by a nack transmitted by the master, since it is the last byte in the transfer. the pec byte is automatically inserted in a master transmitter transmission if pec is enabled when nbytes reaches zero. the pec byte is identified in a master receiver transmission if pec is enabled when nbytes reaches zero. nbytes must therefore be set to the total num- ber of data bytes in the transmission, including the pec byte. s slave address 1st 7 bits p a data rw a1 a2 slave address 2nd byte a data 11110xx0 sr slave address 1st 7 bits rw a3 11110xx1
712 32117b?avr-03/11 at32uc3c in combined transfers, the pecen bit should only be set in the last of the combined transfers. consider the fo llowing transfer: s, adr+w, command_byte, ack, sr, adr+ r, data_byte, ack, pec_byte, nack, p this transfer is generated by writing two commands to the command registers. the first com- mand is a write with nbytes=1 and pecen=0, and the second is a read with nbytes=2 and pecen=1. writing a one to the stop bit in cr will pl ace a stop condition on the bus after the current byte. no pec byte will be sent in this case. 27.8.9.2 timeouts the tlows and tlowm fields in smbtr confi gure the smbus timeout values. if a timeout occurs, the master will transmit a stop condition and leave the bus. the sr.tout bit is also set. 27.8.9.3 smbus alert signal a slave can get the master?s attention by pu lling the twalm line low. sr.smbal will then be set. this can be set up to trigger an interrupt, and software can then take the appropriate action, as defined in the smbus standard. 27.8.10 identifying bus events this chapter lists the different bus events, and how these affects bits in the twim registers. this is intended to help writing drivers for the twim. table 27-5. bus events event effect master transmitter has sent a data byte sr.thr is cleared. master receiver has received a data byte sr.rhr is set. start+sadr sent, no ack received from slave sr.anak is set. sr.ccomp not set. cmdr.valid remains set. stop automatically transmitted on bus. data byte sent to slave, no ack received from slave sr.dnak is set. sr.ccomp not set. cmdr.valid remains set. stop automatically transmitted on bus. arbitration lost sr.arblst is set. sr.ccomp not set. cmdr.valid remains set. twck and twd immediately released to a pulled-up state. smbus alert received sr.smbal is set. smbus timeout received sr.smbtout is set. sr.ccomp not set. cmdr.valid remains set. stop automatically transmitted on bus.
713 32117b?avr-03/11 at32uc3c master transmitter receives smbus pec error sr.dnak is set. sr.ccomp not set. cmdr.valid remains set. stop automatically transmitted on bus. master receiver discovers smbus pec error sr.pecerr is set. sr.ccomp not set. cmdr.valid remains set. stop automatically transmitted on bus. cr.stop is written by user sr.stop is set. sr.ccomp set. cmdr.valid remains set. stop transmitted on bus after curr ent byte transfer has finished. table 27-5. bus events event effect
714 32117b?avr-03/11 at32uc3c 27.9 user interface note: 1. the reset values for these registers are device specific. please refer to the module configuration section at the end of this chapter. table 27-6. twim register memory map offset register register name access reset 0x00 control cr write-only 0x00000000 0x04 clock waveform generator cwgr read/write 0x00000000 0x08 smbus timing smbtr read/write 0x00000000 0x0c command cmdr read/write 0x00000000 0x10 next command ncmdr read/write 0x00000000 0x14 receive holding rhr read-only 0x00000000 0x18 transmit holding thr write-only 0x00000000 0x1c status sr read-only 0x00000002 0x20 interrupt enable register ier write-only 0x00000000 0x24 interrupt disable register idr write-only 0x00000000 0x28 interrupt mask register imr read-only 0x00000000 0x2c status clear register scr write-only 0x00000000 0x30 parameter register pr read-only (1) 0x34 version register vr read-only (1)
715 32117b?avr-03/11 at32uc3c 27.9.1 control register (cr) name: cr access type: write-only offset: 0x00 reset value: 0x00000000 ? stop: stop the current transfer writing a one to this bit terminates the current transfer, sendi ng a stop condition after the shifter has become idle. if there are additional pending transfers, they will have to be explicitly re started by software after the stop condition has been successfu lly sent. writing a zero to this bit has no effect. ? swrst: software reset if the twim master interface is enabled, writing a one to this bit resets the twim. all transfers are halted immediately, possi bly violating the bus semantics. if the twim master interface is not enabled, it must first be enabled before writing a one to this bit. writing a zero to this bit has no effect. ? smdis: smbus disable writing a one to this bit disables smbus mode. writing a zero to this bit has no effect. ? smen: smbus enable writing a one to this bit enables smbus mode. writing a zero to this bit has no effect. ? mdis: master disable writing a one to this bit disables the master interface. writing a zero to this bit has no effect. ? men: master enable writing a one to this bit enables the master interface. writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------stop 76543210 swrst - smdis smen - - mdis men
716 32117b?avr-03/11 at32uc3c 27.9.2 clock waveform generator register (cwgr) name: cwgr access type: read/write offset: 0x04 reset value: 0x00000000 ? exp: clock prescaler used to specify how to prescale the twck clock. coun ters are prescaled according to the following formula ? data: data setu p and hold cycles clock cycles for data setup and hold count. prescaled by cwgr.exp . used to time t hd_dat , t su_dat . ? stasto: start and stop cycles clock cycles in clock high count. prescaled by cwgr.exp. used to time t hd_sta , t su_sta , t su_sto ? high: clock high cycles clock cycles in clock high count. prescaled by cwgr.exp. used to time t high . ? low: clock low cycles clock cycles in clock low count. pre scaled by cwgr.exp. used to time t low , t buf . 31 30 29 28 27 26 25 24 - exp data 23 22 21 20 19 18 17 16 stasto 15 14 13 12 11 10 9 8 high 76543210 low f prescaled f clkpb 2 exp 1 + () ----------------------- - =
717 32117b?avr-03/11 at32uc3c 27.9.3 smbus timing register (smbtr) name: smbtr access type: read/write offset: 0x08 reset value: 0x00000000 ? exp: smbus timeout clock prescaler used to specify how to prescale the ti m and tlowm counters in smbtr. counters are prescaled according to the following formula ? thmax: clock high maximum cycles clock cycles in clock high maximum count. prescaled by smbtr.exp. used for bus free de tection. used to time t high:max . note: uses the prescaler specified by cw gr, not the prescaler specified by smbtr. ? tlowm: master clock stretch maximum cycles clock cycles in master maximum clock stretch count. prescaled by smbtr.exp. used to time t low:mext ? tlows: slave clock stretch maximum cycles clock cycles in slave maximum clock stretch coun t. prescaled by smbtr.exp. used to time t low:sext . 31 30 29 28 27 26 25 24 exp ---- 23 22 21 20 19 18 17 16 thmax 15 14 13 12 11 10 9 8 tlowm 76543210 tlows f prescaled smbus , f clkpb 2 exp 1 + () ----------------------- - =
718 32117b?avr-03/11 at32uc3c 27.9.4 command register (cmdr) name: cmdr access type: read/write offset: 0x0c reset value: 0x00000000 ? acklast: ack last master rx byte writing this bit to zero causes the last byte in master re ceive mode (when nbytes has reached 0) to be nacked. this is the standard way of ending a master receiver transfer. writing this bit to one causes the last byte in master rece ive mode (when nbytes has reached 0) to be acked. used for performing linked transfers in master re ceiver mode with no stop or repeated start between the subtransfers. this is needed when more than 255 bytes are to be received in one single transmission. ? pecen: packet error checking enable writing this bit to zero causes the transfer not to use pec by te verification. the pec lfsr is still updated for every bit transmitted or received. must be used if smbus mode is disabled. writing this bit to one causes the transfer to use pec. pec byte generation (if master transmitter) or pec byte verification (i f master receiver) will be performed. ? nbytes: number of data bytes in transfer the number of data bytes in the transfer. after the specified number of bytes have been transferred, a stop condition is transmitted if cmdr.stop is set. in smbus mode, if pec is used, nbytes includes the pec byte, ie there are nbytes-1 data bytes and a pec byte. ? valid: cmdr valid writing this to zero indicates that cmdr does not contain a valid command. writing this to one indicates that cmdr contains a valid command. this bit is cleared when the command is finished. ? stop: send stop condition write this bit to zero to not transmit a stop condition after the data bytes have been transmitted. write this bit to one to transmit a stop condition after the data bytes have been transmitted. ? start: send start condition write this bit to zero if the transfer in cmdr should not commence with a start or repeated start condition. write this bit to one if the transfer in cmdr should commence with a start or repeate d start condition. if the bus is free when the command is execut ed, a start condition is us ed, if the bus is busy, a repeated start is used. ? repsame: transfer is to same address as previous address only used in 10-bit addressing mode, always write to 0 in 7-bit addressing mode. 31 30 29 28 27 26 25 24 - -- - -- acklast pecen 23 22 21 20 19 18 17 16 nbytes 15 14 13 12 11 10 9 8 valid stop start repsame tenbit sadr[9:7] 76543210 sadr[6:0] read
719 32117b?avr-03/11 at32uc3c write this bit to one if the command in cmdr performs a repeated start to the same slave address as addressed in the previous transfer in order to enter master receiver mode. write this bit to zero otherwise. ? tenbit: ten bit addressing mode write this bit to zero to use 7-bit addressing mode. write this bit to one to use 10-bit addressing mode. must not be used when twim is in smbus mode. ? sadr: slave address address of the slave involved in the transfer. bi ts 9-7 are don?t care if 7-bit addressing is used. ? read: transfer direction write this bit to zero to let the master transmit data. write this bit to one to le t the master receive data.
720 32117b?avr-03/11 at32uc3c 27.9.5 next command register (ncmdr) name: ncmdr access type: read/write offset: 0x10 reset value: 0x00000000 this register is identical to cmdr. when the valid bit in cmdr becomes 0, the contents of ncmdr is copied into cmdr, clearing the valid bit in ncmdr. if the valid bit in cmdr is cleared when ncmdr is written, the contents are copied immediately. 31 30 29 28 27 26 25 24 - --- - --- acklast pecen 23 22 21 20 19 18 17 16 nbytes 15 14 13 12 11 10 9 8 valid stop start repsame tenbit sadr[9:7] 76543210 sadr[6:0] read
721 32117b?avr-03/11 at32uc3c 27.9.6 receive holding register (rhr) name: rhr access type: read-only offset: 0x14 reset value: 0x00000000 ? rxdata: received data when the rxrdy bit in the status regist er (sr) is set, this field contains a byte received from the twi bus. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 rxdata
722 32117b?avr-03/11 at32uc3c 27.9.7 transmit holding register (thr) name: thr access type: write-only offset: 0x18 reset value: 0x00000000 ? txdata: data to transmit write data to be transf erred on the twi bus here. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 txdata
723 32117b?avr-03/11 at32uc3c 27.9.8 status register (sr) name: sr access type: read-only offset: 0x1c reset value: 0x00000002 ? menb: master interface enable 0: master interface is disabled. 1: master interface is enabled. ? stop: stop request accepted this bit is set when stop request caused by sett ing cr stop has been accepted, and transfer has stopped. this bit is cleared by writing 1 to the corresp onding bit in the status clear register (scr). ? pecerr: pec error this bit is set when a smbus pec error occurred. this bit is cleared by writing 1 to the corresp onding bit in the status clear register (scr). ?tout: timeout this bit is set when a smbus timeout occurred. this bit is cleared by writing 1 to the corresp onding bit in the status clear register (scr). ? smbalert: smbus alert this bit is set when an smbus alert was received. this bit is cleared by writing 1 to the corresp onding bit in the status clear register (scr). ? arblst: arbitration lost this bit is set when the actual state of the sda line did not correspond to the data driven onto it, indicating a higher-priori ty transmission in progress by a different master. this bit is cleared by writing 1 to the corresp onding bit in the status clear register (scr). ? dnak: nak in data phase received this bit is set when no ack was received form slave during data transmission. this bit is cleared by writing 1 to the corresp onding bit in the status clear register (scr). ? anak: nak in address phase received this bit is set when no ack was received from slave during address phase this bit is cleared by writing 1 to the correspo nding bit in the status clear register (scr). ? busfree: two-wire bus is free this bit is set when activity has completed on the two-wire bus. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------menb 15 14 13 12 11 10 9 8 - stop pecerr tout smbalert arblst dnak anak 76543210 - - busfree idle ccomp crdy txrdy rxrdy
724 32117b?avr-03/11 at32uc3c otherwise, this bit is cleared. ? idle: master interface is idle this bit is set when no command is in progress, and no command waiting to be issued. otherwise, this bit is cleared. ? ccomp: command complete this bit is set when the current command has completed successfully. not set if the command failed due to conditions such as a nak receved from slave. this bit is cleared by writing 1 to the corresp onding bit in the status clear register (scr). ? crdy: ready for more commands this bit is set when cmdr and/or ncmdr is ready to receive one or more commands. this bit is cleared when this is no longer true. ? txrdy: thr data ready this bit is set when thr is ready for one or more data bytes. this bit is cleared when this is no longer tr ue (i.e. thr is full or transmission has stopped). ? rxrdy: rhr data ready this bit is set when rx data are ready to be read from rhr. this bit is cleared when this is no longer true.
725 32117b?avr-03/11 at32uc3c 27.9.9 interrupt enable register (ier) name: ier access type: write-only offset: 0x20 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - stop pecerr tout smbalert arblst dnak anak 76543210 - - busfree idle ccomp crdy txrdy rxrdy
726 32117b?avr-03/11 at32uc3c 27.9.10 interrupt disable register (idr) name: idr access type: write-only offset: 0x24 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 --------- 15 14 13 12 11 10 9 8 - stop pecerr tout smbalert arblst dnak anak 76543210 - - busfree idle ccomp crdy txrdy rxrdy
727 32117b?avr-03/11 at32uc3c 27.9.11 interrupt mask register (imr) name: imr access type: read-only offset: 0x28 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 --------- 15 14 13 12 11 10 9 8 - stop pecerr tout smbalert arblst dnak anak 76543210 - - busfree idle ccomp crdy txrdy rxrdy
728 32117b?avr-03/11 at32uc3c 27.9.12 status clear register (scr) name: scr access type : write-only offset: 0x2c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in sr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 --------- 15 14 13 12 11 10 9 8 - stop pecerr tout smbalert arblst dnak anak 76543210 ----ccomp---
729 32117b?avr-03/11 at32uc3c 27.9.13 parameter register (pr) name: pr access type: read-only offset: 0x30 reset value: 0x00000000 ? 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
730 32117b?avr-03/11 at32uc3c 27.9.14 version register (vr) name: vr access type: read-only offset: 0x34 reset value: device-specific ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. ? ? 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 ---- version [11:8] 76543210 version [7:0]
731 32117b?avr-03/11 at32uc3c 27.10 module configuration the specific configuration for ea ch twim instance is listed in the following tables. the module bus clocks listed here are connected to the syst em bus clocks. please refer to the power man- ager chapter for details. table 27-7. module configuration feature twim0 twim1 twim2 smbus alert interface implemented implemented not implemented table 27-8. module clock name module name clock name description twim0 clk_twim0 peripheral bus clock from the pba clock domain twim1 clk_twim1 peripheral bus clock from the pba clock domain twim2 clk_twim2 peripheral bus clock from the pbc clock domain table 27-9. register reset values register reset value vr 0x0000 0101 pr 0x0000 0000
732 32117b?avr-03/11 at32uc3c 28. two-wire slave interface (twis) rev: 1.2.0.1 28.1 features ? compatible with i 2 c standard ? 100 and 400 kbit/sin transfer speeds ? 7 and 10-bit and general call addressing ? compatible with smbus standard ? hardware packet error checking (crc) ge neration and verification with ack response ? smbalert interface ? 25 ms clock low timeout delay ? 25 ms slave cumulative clock low extend time ? compatible with pmbus ? dma interface for reducing cpu load ? arbitrary transfer lengths, including 0 data bytes ? optional clock stretching if transmit or receive buffers not ready for data transfer ? 32-bit peripheral bus interface fo r configuration of the interface 28.2 overview the atmel two-wire interface slave (twis) interconnects components on a unique two-wire bus, made up of one clock line and one data line with speeds of up to 400 kbit/s, based on a byte-oriented transfer format. it can be used with any atmel two-wire interface bus i2c or smbus compatible master. twis is always a bus slave and can transfer sequential or single bytes. below, table 28-1 on page 732 lists the compatibility level of the atmel two-wire slave interface and a full i2c compatible device. note: 1. start + b000000001 + ack + sr table 28-1. atmel twis compatibility with i2c standard i2c standard atmel twis standard-mode (100 kbit/s) supported fast-mode (400 kbit/s) supported 7 or 10 bits slave addressing supported start byte (1) not supported repeated start (sr) condition supported ack and nak management supported slope control and input filtering (fast mode) supported clock stretching supported
733 32117b?avr-03/11 at32uc3c below, table 28-2 on page 733 lists the compatibility level of the atmel two-wire slave interface and a full smbus compatible device. 28.3 list of abbreviations 28.4 block diagram figure 28-1. block diagram table 28-2. atmel twis compatibilit y with smbus standard smbus standard atmel twis bus timeouts supported address resolution protocol supported alert supported packet error checking supported table 28-3. abbreviations abbreviation description twi two-wire interface a acknowledge na non acknowledge pstop sstart sr repeated start sadr slave address adr any address except sadr r read wwrite peripheral bus bridge two-wire interface i/o controller twck twd interrupt controller twi interrupt power manager clk_twis twalm
734 32117b?avr-03/11 at32uc3c 28.5 application block diagram figure 28-2. application block diagram 28.6 i/o lines description 28.7 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 28.7.1 i/o lines twd and twck are bidirectional lines, connected to a positive supply voltage via a current source or pull-up resistor (see figure 28-5 on page 736 ). when the bus is free, both lines are high. the output stages of devices connected to the bus must have an open-drain or open-col- lector to perform the wired-and function. twalm is used to implement the optional smbus smbalert signal. twalm, twd, and twck pins may be multiple xed with i/o controller lines. to enable the twis, the programmer must perform the following steps: ? program the i/o controller to: ? dedicate twd, twck and optionally twalm as peripheral lines. ? define twd, twck and optionally twalm as open-drain. host with twi interface twd twck atmel twi serial eeprom i2c rtc i2c lcd controller slave 1 slave 2 slave 3 vdd i2c temp. sensor slave 4 rp: pull up value as given by the i2c standard rp rp table 28-4. i/o lines description pin name pin description type twd two-wire serial data input/output twck two-wire serial clock input/output twalm smbus smbalert input/output
735 32117b?avr-03/11 at32uc3c 28.7.2 power management if the cpu enters a sleep mode that disables cl ocks used by the twis, the twis will stop func- tioning and resume operation after the system wakes up from sleep mode. twis is able to wake the system from sleep mode upon address match, see section 28.8.8 on page 743 . 28.7.3 clocks the clock for the twis bus interface (clk_twis) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to dis- able the twis before disabling the clock, to avoid freezing the twis in an undefined state. 28.7.4 dma the twis dma handshake interface is connected to the peripheral dma controller. using the twis dma functionality requires the peripheral dma controller to be programmed after setting up the twis. 28.7.5 interrupts the twis interrupt request lines are connected to the interrupt controller. using the twis inter- rupts requires the interrupt controller to be programmed first. 28.7.6 debug operation when an external debugger forces the cpu into debug mode, the twis continues normal oper- ation. if the twis is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. 28.8 functional description 28.8.1 transfer format the data put on the twd line must be 8 bits long. data is transferred msb first; each byte must be followed by an acknowledgement. the number of bytes per transfer is unlimited (see figure 28-4 on page 736 ). each transfer begins with a start condition and terminates with a stop condition (see figure 28-3 on page 735 ). ? a high-to-low transition on the twd line while twck is high defines the start condition. ? a low-to-high transition on the twd line while twck is high defines a stop condition. figure 28-3. start and stop conditions twd twck start stop
736 32117b?avr-03/11 at32uc3c figure 28-4. transfer format 28.8.2 operation twis has two modes of operation: ? slave transmitter mode ? slave receiver mode a master is a device which starts and stops a transfer and generates the twck clock. a slave is assigned an address and responds to requests from the master. these modes are described in the following chapters. figure 28-5. typical application block diagram twd twck start address r/w ack data ack data ack stop host with twi interface twd twck atmel twi serial eeprom i2c rtc i2c lcd controller slave 1 slave 2 slave 3 vdd i2c temp. sensor slave 4 rp: pull up value as given by the i2c standard rp rp
737 32117b?avr-03/11 at32uc3c 28.8.2.1 bus timing the timing register (tr) is used to control the timing of bus signals driven by twis. tr describes bus timings as a function of cycles of the prescaled clk_twis. the clock prescaling can be selected through tr.exp. tr has the following fields: tlows: prescaled clock cycles used to time smbus timeout t low:sext . ttout: prescaled clock cycles us ed to time smbus timeout t timeout . sudat: non-prescaled clock cycles for data setup and hold count. used to time t su_dat . exp: specifies the clock prescaler setting used for the smbus timeouts. figure 28-6. bus timing diagram 28.8.2.2 setting up and performing a transfer operation of twis is mainly controlled by the control register (cr). th e following list presents the main steps in a typical communication: 1. before any transfers can be performed, bus timings must be configured by program- ming the timing register (tr). 2. if a dma controller is to be used for the transfers, it must be set up. 3. the control register (cr) must be configured with information such as the slave address, smbus mode, packet error checking (pec), number of bytes to transfer, and which addresses to match. the interrupt system can be set up to give interr upt request on specific events or error condi- tions, for example when a byte has been received. f prescaled f clk twis ? 2 exp 1 + ) () --------------------------- = s t hd:sta t low t su:dat t high t hd:dat t low p t su:sto sr t su:sta t su:dat
738 32117b?avr-03/11 at32uc3c the nbytes register is only used in smbus mode, when pec is enabled. in i2c mode or in smbus mode when pec is disabled, the nbytes register is not used, and should be written to 0. nbytes is updated by hardware, so in order to avoid hazards, software updates of nbytes can only be done through writes to the nbytes register. 28.8.2.3 address matching twis can be set up to match several different addresses. more than one address match may be enabled simultaneously, allowing twis to be assigned to several addresses. the address matching phase is initiated after a start or repeated start condition. when twis receives an address that generates an address matc h, an ack is automatically returned to the master. in i2c mode: ? the address in cr.adr is checked fo r address match if cr.smatch is set. ? the general call address is checked fo r address match if cr.gcmatch is set. in smbus mode: ? the address in cr.adr is checked fo r address match if cr.smatch is set. ? the alert response address is checked for address match if cr.smal is set. ? the default address is checked for address match if cr.smda is set. ? the host header address is checked for address match if cr.smhh is set. 28.8.2.4 clock stretching any slave or bus master taking part in a transfer may extend the twck low period at any time. twis may extend the twck low period after each byte transfer if cr.stren=1 and: ? module is in slave transmitter mode, data should be transmitted, but thr is empty, or ? module is in slave receiver mode, a byte has been received and placed into the internal shifter, but rhr is full, or ? stretch-on-address-match bit cr.soam=1 and slave was addressed. bus clock remains stretched until all address match bits in sr have been cleared. if cr.stren=0 and: ? module is in slave transmitter mode, data shou ld be transmitted but thr is empty: transmit the value present in thr (the last transmitted byte or reset value), and set sr.urun. ? module is in slave receiver mode, a byte has been received and placed into the internal shifter, but rhr is full: discard the received byte and set sr.orun. 28.8.2.5 bus errors if a bus error (misplaced start or stop) cond ition is detected, the sr.buserr bit is set and twis waits for a new start condition. 28.8.3 slave transmitter mode if twis matches an address in which the r/w bit in the twi address phase transfer is set, it will enter slave transmitter mode and set the sr.tra bit (note that sr.tra is set one clk_twis cycle after the relevant address match bit in the same register is set). after the address phase, the following actions are performed:
739 32117b?avr-03/11 at32uc3c 1. if smbus mode and pec is used, nbytes must be set up with the number of bytes to transmit. this is necessary in order to know when to transmit pec byte. nbytes can also be used to count the number of bytes received if using dma. 2. byte to transmit depends on i2c/smbus mode and cr.pec: ? if in i2c mode or cr.pec=0 or nbytes!=0 : twis waits until thr contains a valid data byte, possibly stretching the low period of twck. after thr contains a valid data byte, the data byte is transferred to a shifter, and then sr.txrdy is changed to one because the thr is empty again. ? smbus mode and cr.pec=1: if nbytes=0, the generated pec byte is automatically transmitted in stead of a data byte from thr. twck will not be stretched by twis. 3. the data byte in the shifter is transmitted. 4. nbytes is updated. if cr.cup is set, nbytes is incremented, otherwise nbytes is decremented. 5. after each data byte has been transmitted, the master transmits an ack (acknowledge) or nak (not acknowledge) bit. if a nak bit is received by twis, the sr.nak bit is set. note that this is done two clk_twis cycles after twck has been sampled by twis to be high (see figure 28-9 on page 740 ). the nak indicates that the transfer is finished, and twis will wait for a stop or repeated start. if an ack bit is received, the sr.nak bit remains low. the ack indicates that more data should be transmitted, so jump to step 2. at the end of the ack/nak clock cycle, the sr.btf (byte transfer fin- ished) bit is set. note that this is done two clk_twis cycles after twck has been sampled by twis to be low (see figure 28-9 on page 740 ). also note that in the event that sr.nak bit is set, it must not be cleared before the sr.btf bit is set to ensure cor- rect twis behavior. 6. if stop is received, sr.tcomp and sr.sto will be set. 7. if repeated start is received, sr.rep will be set. the twi transfers require the receiver to acknowledge each received data byte. during the acknowledge clock pulse (9th pulse), the slave releases the data line (high), enabling the mas- ter to pull it down in order to generate the acknowledge. the slave polls the data line during this clock pulse and sets the nak bit in the status register if the master does not acknowledge the data byte. a nak means that the master does not wish to receive additional data bytes. as with the other status bits, an interrupt can be gener ated if enabled in the interrupt enable register (ier). txrdy is used as transmit ready for the pe ripheral dma controller transmit channel. the end of the complete transfer is marked by the sr.tcomp bit set to one. see figure 28-7 on page 740 and figure 28-8 on page 740 .
740 32117b?avr-03/11 at32uc3c figure 28-7. slave transmitter with one data byte figure 28-8. slave transmitter with multiple data bytes figure 28-9. timing relationship between twck, sr.nak, and sr.btf 28.8.4 slave receiver mode if twis matches an address in which the r/w bit in the twi address phase transfer is cleared, it will enter slave receiver mode and clear sr.t ra (note that sr.tra is cleared one clk_twis cycle after the relevant address match bit in the same register is set). after the address phase, the following is repeated: 1. if smbus mode and pec is used, nbytes must be set up with the number of bytes to receive. this is necessary in order to know which of the received bytes is the pec byte. nbytes can also be used to count the number of bytes received if using dma. 2. receive a byte. set sr.btf when done. tcomp txrdy write thr (data) stop sent by master twd adatan sdadrr p nbytes set to 1 adata na sdadrr data n+5a p data n+m n tco m p txrdy write thr (data n) nbytes set to m stop sent by master twd write thr (data n+1) write thr (data n+m) last data sent data (lsb) n p twck sr.nak sr.btf t 1 t 1 t 1 : (clk_twis period) x 2 twd
741 32117b?avr-03/11 at32uc3c 3. update nbytes. if cr.cup is written to one, nbytes is incremented, otherwise nbytes is decremented. nbytes is usually configured to count downwards if pec is used. 4. after a data byte has been received, the slave transmits an ack or nak bit. for ordi- nary data bytes, the cr.ack field controls if an ack or nak should be returned. if pec is enabled and the last byte received was a pec byte (indicated by nbytes=0), twis will automatically return an ack if the pec value was correct, otherwise a nak will be returned. 5. if stop is received, sr.tcomp will be set. 6. if repeated start is received, sr.rep will be set. the twi transfers require the receiver to acknowledge each received data byte. during the acknowledge clock pulse (9th pulse), the master releases the data line (high), enabling the slave to pull it down in order to generate the acknowledge. the master polls the data line during this clock pulse. rxrdy is used as receive ready for the peripheral dma controller receive channel. figure 28-10. slave receiver with one data byte figure 28-11. slave receiver with multiple data bytes 28.8.5 interactive acking received data bytes when implementing a register interface over twi, it may sometimes be necessary or just useful to report reads and writes to invalid register addresses by sending a nak to the host. to be able to do this, one must first receive the register address from the twi bus, and then tell the twis a sdadrw data ap tcomp rx r dy read rhr twd a a sdadrw data na a data (n+1) a data (n+m) dat a (n+m)-1 p twd tco m p rx r dy read rhr data n read rhr dat a (n+1) read rhr dat a (n+m)-1 read rhr data (n+m)
742 32117b?avr-03/11 at32uc3c whether to ack or nak it. in normal operation of the twis, this is not possible because the con- troller will automatically ack the by te at about the same time as the rxrdy interrup t flag is set. writing a one to the stretch on data byte rece ived bit (cr[sodr]) will stretch the clock allow- ing the user to update cr[ack] bit before returning the desired value. after the last bit in the data byte is received, the twi bus clock is stretched, the received data byte is transferred to the rhr register, and sr[btf] is set. at this time, the user can examine the received byte and write the desired ack or nack value to cr[ack]. when the user clears sr[btf], the desired ack value is transferred on the twi bus. this makes it possible to look at the byte received, deter- mine if it's valid, and then decide to ack or nak it. 28.8.6 using the peripheral dma controller the use of the peripheral dma controller signi ficantly reduces the cpu load. the programmer can set up ring buffers for the dma controller, containing data to transmit or free buffer space to place received data. by initializing nbyt es to 0 before a transfer, and setting cr.cup, nbytes is incremented by 1 each time a data has been transmitted or received. this allows the programmer to detect how much data was actually transferred by the dma system. to assure correct behavior, respect the following programming sequences: 28.8.6.1 data transmit with the peripheral dma controller 1. initialize the transmit peripheral dma controller (memory pointers, size, etc.). 2. configure the twis (adr, nbytes, etc.). 3. start the transfer by setting the peripheral dma controller txten bit. 4. wait for the peripheral dma controller end tx flag. 5. disable the peripheral dma controller by setting the peripheral dma controller txdis bit. 28.8.6.2 data receive with th e peripheral dma controller 1. initialize the receive peripheral dma controller (memory pointers, size - 1 , etc.). 2. configure the twis (adr, nbytes, etc.). 3. start the transfer by setting the peripheral dma controller rxten bit. 4. wait for the peripheral dma controller end rx flag. 5. disable the peripheral dma controller by setting the peripheral dma controller rxdis bit. 28.8.7 smbus mode smbus mode is enabled when cr.smen is writte n to one. smbus mode operation is similar to i2c operation with the following exceptions: ? only 7-bit addressing can be used. ? the smbus standard describes a set of timeout values to ensure progress and throughput on the bus. these timeout values must be programmed into tr. ? transmissions can optionally include a crc byte, called packet error check (pec). ? a dedicated bus line, smbalert, allows a slave to get a master?s attention. ? a set of addresses have been reserved for protocol handling, such as alert response address (ara) and host header (hh) addres s. address matching on these addresses can be enabled by configuring cr appropriately.
743 32117b?avr-03/11 at32uc3c 28.8.7.1 packet error checking each smbus transfer can optionally end with a crc byte, called the pec byte. writing a one to cr.pecen enables automatic pec handling in the current transfer. the pec generator is always updated on every bit transmitted or received, so that pec handling on following linked transfers will be correct. in slave receiver mode, the master calculates a pec value and transmits it to the slave after all data bytes have been tr ansmitted. upon reception of this pec byte, the slave will compare it to the pec value it has computed itself. if the values match, the data was received correctly, and the slave will return an ack to th e master. if the pec values differ, data was corrupted, and the slave will return a nak value. the sr.smbpece rr bit is set automatically if a pec error occurred. in slave transmitter mode, the slave calculates a pec value and transmits it to the master after all data bytes have been transm itted. upon reception of this pec byte, the master will compare it to the pec value it has computed itself. if the values match, the data was received correctly. if the pec values differ, data was corrupted, and the master must take appropriate action. the pec byte is automatically inserted in a slave transmitter transmission if pec enabled when nbytes reaches zero. the pec byte is identified in a slave receiver transmission if pec enabled when nbytes reaches zero. nbytes must therefore be set to the total number of data bytes in the transmission, including the pec byte. 28.8.7.2 timeouts the timing register (tr) configures the smbus timeout values. if a timeout occurs, the slave will leave the bus. the sr.smbtout bit is also set. 28.8.7.3 smbalert a slave can get the master?s attention by pulling the smbalert line low. this is done by setting the cr.smbal bit. this will also enable address match on the alert response address (ara). 28.8.8 wakeup from sleep modes by twi address match twis is able to wake the device up from a slee p mode upon an address match, including sleep modes where clk_twis is stopped. the behavior of twis when a twi start condition is received during a sleep mode where clk_tw is is stopped depends on whether the auxiliary address matching feature is implemented (refer to the module configuration section at the end of this chapter) an d enabled. if implem ented, auxiliary address matchi ng can be enabled by writ- ing a ?1? to the auxiliary ad dress matching (auxam) bit of the control register (cr). if auxiliary address matching is not enabled, tw is will stretch twck until clk_twis has started. the time required for starting clk_twis depends on which sleep mode the device is in. after clk_twis has started, twis releases its twck stretching and receives one byte of data on the bus. at this time, only a limited part of the device, including twis, receives a clock, thus saving power. if the received byte is a master code, twis enters hs-mode (provided that hs- mode is implemented; refer to the module configuration section at the end of this chapter) and goes on to receive the slave address. if the addr ess phase (either in f/s- or hs-mode) causes a twis address match, the entire device is wakened and normal twis address matching actions are performed. normal twi transfer then follows. if twis is not addressed, clk_twis is auto- matically stopped and the device returns to its original sleep mode. if twis is in hs-mode, it remains so until it detects a st op condition on the bus, after which it switches back to f/s- mode.
744 32117b?avr-03/11 at32uc3c on the other hand, if auxilia ry address matching is enabled, twis will operate using twck directly as its clock without stretching twck and waiting for clk_twis to start. if an address match occurs, the entire device is wakened and normal twi transfer follows. the time required for the device to wake up depends on which sleep mode it is in. 28.8.9 identifying bus events this chapter lists the different bus events, and ho w these affects bits in the twis registers. this is intended to help writing drivers for the twis. table 28-5. bus events event effect slave transmitter has sent a data byte sr.thr is cleared. sr.btf is set. the value of the ack bit sent immediately after the data byte is given by cr.ack. slave receiver has received a data byte sr.rhr is set. sr.btf is set. sr.nak updated according to value of ack bit received from master. start+sadr on bus, but address is to another slave none. start+sadr on bus, current slave is addressed, but address match enable bit in cr is not set none. start+sadr on bus, current slave is addressed, corresponding address match enable bit in cr set correct address match bit in sr is set. sr.tra updated according to transfer direction (updating is done one clk_twis cycle af ter address match bit is set) slave enters appropriate transfer direction mode and data transfer can commence. start+sadr on bus, current slave is addressed, corresponding address match enable bit in cr set, sr.stren and sr.soam are set. correct address match bit in sr is set. sr.tra updated according to transfer direction (updating is done one clk_twis cycle af ter address match bit is set). slave stretches twck immediately after transmitting the address ack bit. twck remains stretched until all address match bits in sr have been cleared. slave the enters appropriate transfer direction mode and data transfer can commence. repeated start received after being addressed sr.rep set. sr.tcomp unchanged. stop received after being addressed sr.sto set. sr.tcomp set. start, repeated start or stop received in illegal position on bus sr.buserr set. data is to be received in slave receiver mode, sr.stren is set, and rhr is full twck is stretched until rhr has been read.
745 32117b?avr-03/11 at32uc3c data is to be transmitted in slave receiver mode, sr.stren is set, and thr is empty twck is stretched until thr has been written. data is to be received in slave receiver mode, sr.stren is cleared, and rhr is full twck is not stretched, read data is discarded. sr.orun is set. data is to be transmitted in slave receiver mode, sr.stren is cleared, and thr is empty twck is not stretched, previous c ontents of thr is written to bus. sr.urun is set. smbus timeout received sr.smbtout is set. twck and twd are immediately released. slave transmitter in smbus pec mode has transmitted a pec byte, that was not identical to the pec calculated by the master receiver. master receiver will transmit a nak as usual after the last byte of a master receiver transfer. master receiver will retry th e transfer at a later time. slave receiver discovers smbus pec error sr.smbpecerr is set. nak returned after the data byte. table 28-5. bus events event effect
746 32117b?avr-03/11 at32uc3c 28.9 user interface note: 1. the reset values for these registers are devi ce specific. please refer to the module configura- tion section at the end of this chapter. table 28-6. twis register memory map offset register register name access reset 0x00 control register cr read/write 0x00000000 0x04 nbytes register nbytes read/write 0x00000000 0x08 timing register tr read/write 0x00000000 0x0c receive holding register rhr read-only 0x00000000 0x10 transmit holding register thr write-only 0x00000000 0x14 packet error check register pecr read-only 0x00000000 0x18 status register sr read-only 0x00000002 0x1c interrupt enable register ier write-only 0x00000000 0x20 interrupt disable register idr write-only 0x00000000 0x24 interrupt mask register imr read-only 0x00000000 0x28 status clear register scr write-only 0x00000000 0x2c parameter register pr read-only (1) 0x30 version register vr read-only (1)
747 32117b?avr-03/11 at32uc3c 28.9.1 control register name: cr access type: read/write offset :0x00 reset value: 0x00000000 ? auxam: auxiliary address matching write this bit to zero to disable auxiliary address matching. write this bit to one to enable auxiliary address matching. ? tenbit: ten bit address match write this bit to zero to disable ten bit address match. write this bit to one to enable ten bit address match. ? adr: slave address slave address used in slave address match. bits 9: 0 are used if in 10-bit mode, bits 6:0 otherwise. ? sodr: stretch clock on data byte reception writing this bit to zero will not stretch bus clock immediately before acking a received data byte. writing this bit to one will strech bus clock immediately before acking a received data byte. ? soam: stretch clock on address match writing this bit to zero will not strech bus clock after address match. writing this bit to one will strech bus clock after address match. ? cup: nbytes count up writing this bit to zero causes nbytes to count down (decrement) per byte transferred. writing this bit to one causes nbytes to count up (increment) per byte transferred. ? ack: slave receiver data phase ack value writing this bit to zero causes a low value to be returned in the ack cycle of the data phase in slave receiver mode. writing this bit to one causes a high value to be returned in the ack cycle of the data phase in slave receiver mode. ? pecen: packet error checking enable writing this bit to zero disables smbus pec (crc) generation and check. writing this bit to one enables smbus pec (crc) generation and check. ? smhh: smbus host header writing this bit to zero causes twis not to acknowledge the smbus host header. writing this bit to one causes twis to acknowledge the smbus host header. ? smda: smbus default address writing this bit to zero causes twis not to acknowledge the smbus default address. writing this bit to one causes twis to acknowledge the smbus default address. 31 30 29 28 27 26 25 24 ---- auxam - tenbit adr[9:8] 23 22 21 20 19 18 17 16 adr[7:0] 15 14 13 12 11 10 9 8 sodr soam cup ack pecen smhh smda smbalert 76543210 swrst - - stren gcmatch smatch smen sen
748 32117b?avr-03/11 at32uc3c ? smbalert: smbus alert writing this bit to zero causes twis to release the smbalert line and not to acknowledge the smbus alert response address (ara). writing this bit to one causes twis to pull down the smbalert line and to acknowledge the smbus alert response address (ara). ? swrst: software reset this bit will always read as 0. writing a zero to this bit has no effect. writing a one to this bit resets the twis. ? stren: clock stretch enable writing this bit to zero disables clock stretching if rhr/thr buffer full/empt y. may cause over/underrun. writing this bit to one enables clock stretching if rhr/thr buffer full/empty. ? gcmatch: general call address match writing this bit to zero causes twis no t to acknowledge the general call address. writing this bit to one causes twis to acknowledge the general call address. ? smatch: slave address match writing this bit to zero causes twis not to acknowledge the slave address. writing this bit to one causes twis to acknowledge the slave address. ? smen: smbus mode enable writing this bit to zero disables smbus mode. writing this bit to one enables smbus mode. ? sen: slave enable writing this bit to zero disables the slave interface. writing this bit to one enables the slave interface.
749 32117b?avr-03/11 at32uc3c 28.9.2 nbytes register name: nbytes access type: read/write offset :0x04 reset value: 0x00000000 ? nbytes: number of bytes to transfer writing to this field updates the nbytes counter. can also be r ead to to learn the progress of the transfer. can be incremented or decremented automatically by hardware. 31 30 29 28 27 26 25 24 - 23 22 21 20 19 18 17 16 - 15 14 13 12 11 10 9 8 - 76543210 nbytes
750 32117b?avr-03/11 at32uc3c 28.9.3 timing register name: tr access type: read/write offset :0x08 reset value: 0x00000000 ? exp: clock prescaler used to specify how to prescale the smbus tlows counter. the counter is prescaled according to the following formula: ? sudat: data setup cycles non-prescaled clock cycles for data setup count. used to time t su_dat . data is driven sudat cycles after twck low detected. this timing is used for timing the ack/nak bits, and any data bits driven in slave transmitter mode. ? ttout: smbus ttimeout cycles prescaled clock cycles used to time smbus t timeout . ? tlows: smbus tlow:sext cycles prescaled clock cycles used to time smbus t low:sext . 31 30 29 28 27 26 25 24 exp - 23 22 21 20 19 18 17 16 sudat 15 14 13 12 11 10 9 8 ttout 76543210 tlows f prescaled f clkpb 2 exp 1 + () ----------------------- - =
751 32117b?avr-03/11 at32uc3c 28.9.4 receive holding register name: rhr access type: read-only offset :0x0c reset value: 0x00000000 ? rxdata: received data byte when the rxrdy bit in the status regist er (sr) is set, this field contains a byte received from the twi bus. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 rxdata
752 32117b?avr-03/11 at32uc3c 28.9.5 transmit holding register name: thr access type: write-only offset :0x10 reset value: 0x00000000 ? txdata: data byte to transmit write data to be transf erred on the twi bus here. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 txdata
753 32117b?avr-03/11 at32uc3c 28.9.6 packet error check register name: pecr access type: read-only offset :0x14 reset value: 0x00000000 ? pec: calculated pec value the calculated pec value. updated automatical ly by hardware after each byte has been transferred. reset by hardware after a stop condition. provided if the user manu ally wishes to control when the pec byte is transmitted, or wishes to access the pec value for other reasons. in ordinary operation, the pec handling is done automatically by hardware. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 pec
754 32117b?avr-03/11 at32uc3c 28.9.7 status register name: sr access type: read-only offset :0x18 reset value: 0x000000002 ? btf: byte transfer finished this bit is set when byte transfer has completed. this bit is cleared when the corresponding bit in scr is written to one. ? rep: repeated start received this bit is set when repeated start condition received. this bit is cleared when the corresponding bit in scr is written to one. ? sto: stop received this bit is set when stop condition received. this bit is cleared when the corresponding bit in scr is written to one. ? smbdam: smbus default address match this bit is set when received address matched smbus default address. this bit is cleared when the corresponding bit in scr is written to one. ? smbhhm: smbus host header address match this bit is set when received address matched smbus host header address. this bit is cleared when the corresponding bit in scr is written to one. ? smbalertm: smbus alert response address match this bit is set when received address matched smbus alert response address. this bit is cleared when the corresponding bit in scr is written to one. ? gcm: general call match this bit is set when received address matched general call address. this bit is cleared when the corresponding bit in scr is written to one. ? sam: slave address match this bit is set when received address matched slave address. this bit is cleared when the corresponding bit in scr is written to one. ? buserr: bus error this bit is set when a misplaced start or stop condition has occurred. this bit is cleared when the corresponding bit in scr is written to one. 31 30 29 28 27 26 25 24 - 23 22 21 20 19 18 17 16 btf rep sto smbdam smbhhm smbalertm gcm sam 15 14 13 12 11 10 9 8 - buserr smbpecerr smbtout - - - nak 76 5 43210 orun urun tra - tcomp sen txrdy rxrdy
755 32117b?avr-03/11 at32uc3c ? smbpecerr: smbus pec error this bit is set when smbus pec error has occurred. this bit is cleared when the corresponding bit in scr is written to one. ? smbtout: smbus timeout this bit is set when smbus timeout has occurred. this bit is cleared when the corresponding bit in scr is written to one. ? nak: nak received this bit is set when nak was received from master during slave transmitter operation. this bit is cleared when the corresponding bit in scr is written to one. ? orun: overrun this bit is set when overrun has occurred in slave receiver mode. can only occur if cr.stren=0. this bit is cleared when the corresponding bit in scr is written to one. ? urun: underrun this bit is set when underrun has occurred in slave transmitter mode. can only occur if cr.stren=0. this bit is cleared when the corresponding bit in scr is written to one. ? tra: transmitter mode 0: the slave is in slave receiver mode. 1: the slave is in slave transmitter mode. ? tcomp: transmis sion complete this bit is set when transmission is complete. set after receiving a stop after being addressed. this bit is cleared when the corresponding bit in scr is written to one. ? sen: slave enabled 0: the slave interface is disabled. 1: the slave interface is enabled. ? txrdy: tx buffer ready 0: the tx buffer is full and should not be written to. 1: the tx buffer is empty, and can accept new data. ? rxrdy: rx buffer ready 0: no rx data ready in rhr. 1: rx data is ready to be read from rhr.
756 32117b?avr-03/11 at32uc3c 28.9.8 interrupt enable register name: ier access type: write-only offset :0x1c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -- - ----- 23 22 21 20 19 18 17 16 btf rep sto smbdam smbhhm smbalertm gcm sam 15 14 13 12 11 10 9 8 - buserr smbpecerr smbtout - - - nak 76 5 43210 orun urun - - tcomp - txrdy rxrdy
757 32117b?avr-03/11 at32uc3c 28.9.9 interrupt disable register name: idr access type: write-only offset :0x20 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -- - ----- 23 22 21 20 19 18 17 16 btf rep sto smbdam smbhhm smbalertm gcm sam 15 14 13 12 11 10 9 8 - buserr smbpecerr smbtout - - - nak 76 5 43210 orun urun - - tcomp - txrdy rxrdy
758 32117b?avr-03/11 at32uc3c 28.9.10 interrupt mask register name: imr access type: read-only offset :0x24 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -- - ----- 23 22 21 20 19 18 17 16 btf rep sto smbdam smbhhm smbalertm gcm sam 15 14 13 12 11 10 9 8 - buserr smbpecerr smbtout - - - nak 76 5 43210 orun urun - - tcomp - txrdy rxrdy
759 32117b?avr-03/11 at32uc3c 28.9.11 status clear register name: scr access type: write-only offset :0x28 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in sr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 - 23 22 21 20 19 18 17 16 btf rep sto smbdam smbhhm smbalertm gcm sam 15 14 13 12 11 10 9 8 - buserr smbpecerr smbtout - - - nak 76 5 43210 orun urun - - tcomp - - -
760 32117b?avr-03/11 at32uc3c 28.9.12 parameter register name: pr access type: read-only offset :0x2c reset value: 0x00000000 ? auxam: auxiliary address matching 0: auxiliary address matching is not supported. 1: auxiliary address matching is supported. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------- auxam -
761 32117b?avr-03/11 at32uc3c 28.9.13 version register (vr) name: vr access type: read-only offset: 0x30 reset value: device-specific ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 ---- version [11:8] 76543210 version [7:0]
762 32117b?avr-03/11 at32uc3c 28.10 module configuration the specific configuration for each twis instance is listed in the following tables. the module bus clocks listed here are connected to the syst em bus clocks. please refer to the power man- ager chapter for details. table 28-7. module configuration feature twim0 twim1 twim2 smbus alert interface implemented implemented not implemented table 28-8. module clock name module name clock name description twis0 clk_twis0 peripheral bus clock from the pba clock domain twis1 clk_twis1 peripheral bus clock from the pba clock domain twis2 clk_twis2 peripheral bus clock from the pbc clock domain table 28-9. register reset values register reset value vr 0x00000120 pr 0x00000000
763 32117b?avr-03/11 at32uc3c 29. can interface (canif) version 1.1.0.3 29.1 features ? supports can 2.0a and 2. 0b protocol specifications ? 1 mb/s maximum bitrate ? 2 can channels ? 16 message objects per can channel ? 1 identifier (11 or 29 bits), 1 identi fier mask and 8 bytes buffer per mob ? single shot and automati c transmit/receive modes ? overrun mode ? loop-back mode for bit rate detection ? listen mode for bus monitoring ? system sleep mode support with wake-up on bus activity ? programmable can clock source 29.2 overview control area network (can) is a serial communication protocol with high level of security. each node is master on the bus but only one at a time is able to send a message. canif is a 32-bit interface fo r can channels. each channel provides the following services: ? message filtering ? message and status handling ? fault confinement ? error detection and signalling ? message validation and acknowledgement ? bus arbitration ? message framing ? transfer rate and timing these services, with the exception of message f iltering and message handling, are described in the can protocol, please refer to bosch - can specification for more details.
764 32117b?avr-03/11 at32uc3c 29.3 block diagram figure 29-1. canif block diagram 29.4 i/o lines description 29.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 29.5.1 i/o lines canif pins are multiplexed with other peripheral s. user must first program the i/o controller to give control of the pins to the canif. 29.5.2 power management if the cpu enters a sleep mode that disables clocks used by ca nif, it will stop functioning and resume operation after the system wakes up from sleep mode. 29.5.3 clocks canif is connected to both the hsb and the pb, and therefore uses a hsb clock (clk_canif_hsb) and a pb cl ock (clk_canif_pb). these clocks are generated by the power manager. these clocks are enabled at reset, and can be disabled in the power manager. canif uses a gclk as clock source (c an clock) for the can bus communication (gclk_canif). user must make sure this clock is running and frequency is correct before any operation. 29.5.4 memory messages can be stored in cpu or hsb ram, so user must allocate ram space for can messages. ram hsb txline(0) rxline(0) . . . pb msg handling & filtering protocol engine canif can clock txline(n) rxline(n) table 29-1. i/o lines description pin name pin description type txline(n) transmission line of channel n output rxline(n) reception line of channel n input
765 32117b?avr-03/11 at32uc3c 29.5.5 interrupts canif interrupt request line is connected to the interrupt contro ller. using the canif interrupt requires the interrupt controller to be programmed first. 29.5.6 debug operation all can channels are disabled when the cpu enters debug mode. communication in progress is not stopped. please refer to the on-chip debug chapter in the avr32uc technical refer- ence manual, and the ocd module configuration section, for details. 29.6 functional description 29.6.1 channel configuration channel configuration is done via the configurat ion register (cancfg). this register is not write accessible once the channels have been enabled. 29.6.1.1 bit timing this section refers to chapter 8 (bit timing requirements) of the can specification. the can bit rate is defined by the nominal bit time. nominal bit time is divided into 4 time segments. figure 29-2. partition of the bit time the duration of each time segment is divided into time quanta (tq). the total number of tq in a bit time must be in the range [8..25]. the time quantum is a fixed unit of time derived from the gclk_canif clock period: tq = prescaler x p gclk_canif = (cancfg.pres+1) x p gclk_canif re-synchronization may lengthen or shorten the bit time, the upper bound is given by synchroni- zation jump width field in the configuration register (cancfg.sjw). the value of all previous parameters are defined in cancfg register. table 29-2. can parameter settings parameter range cancfg field sync_seg 1 - prop_seg [1..8]tq prs + 1 phase_seg1 [1..8]tq phs1 + 1 sync_seg prop_seg phase_seg1 phase_seg2 nominal bit time sample point
766 32117b?avr-03/11 at32uc3c the bit duration is given by the formula: tbit = (prs + phs1 + phs2 + 4) x (pres + 1) x p gclk_canif note: pres should not be set to 0, theref ore can clock is at least divided by 2. 29.6.1.2 sampling method bits are sampled between phase_seg1 and ph ase_seg2. by writing the sampling method bit (cancfg.sm) to one, three samples are taken and a majority vote is performed. figure 29-3. sampling by majority voting majority voting must not be used when the pr escaler field (cancfg.pres) is equal to zero. 29.6.1.3 operating modes canif has three operating modes, selectable by the channel mode field (cancfg.cmode): ? normal mode (cancfg.cmode=00) default mode, tx and rx lines are connected to the transceiver. this mode is used to communicate with other nodes on the bus. ? listening mode (cancfg.cmode=01) the tx line is disconnected from the transceiver. the can channel cannot send any message nor acknowledge when a message has been received. the channel is in error passive mode and transmit/receive error counters (tec/rec) are frozen. this mode is used to listen to can bus. ? loop back mode (cancfg.cmode=10) the tx line is internally connected to the rx line and disconnected from the transceiver. the can channel can only send messages or acknowledges to itself. the channel is in error passive mode and tec/rec are frozen. this mode is used to detect the bit rate of the can bus by successive configuration of bit timing. 29.6.1.4 overrun mode when overrun mode is disabled, the mob is dis abled after successfully receiving a message. this prevents overwriting the received message if a second message is received. overrun mode is disabled by writing a zero to cancfg.ov rm. overrun mode is disabled by default. phase_seg2 [1..8]tq phs2 + 1 prescaler [2..32] pres + 1 sync jump width [1..4] sjw + 1 table 29-2. can parameter settings parameter range cancfg field phase_seg1 phase_seg2 s1 s2 sp can clock bit samples
767 32117b?avr-03/11 at32uc3c when overrun mode is enabled, the mob is not disabled after a successful reception. overrun mode is enabled by writing a one to cancfg.ovr m. the overwrite bit in the mob status reg- ister (mobsr.ovw) is set if a previously received message has been overwritten. the mode configured by cancfg.ovrm is us ed by all mobs configured for reception. 29.6.1.5 memory pointer each channel uses a section of ram for stori ng messages. user must allocate ram space for the channels and store the base address of this space into the channel ram base address register (canramb). four words per mob in use must be allocated. channels operate independently so the allocated memory spaces do not need to be consecu- tive. make sure that the memory spaces do not overlap. 29.6.2 channel handling 29.6.2.1 initialization can channels are initialized by writing a one to the initialization bit in the control register (canctrl.init). initialization resets all internal state machines and clears all user interface registers except can- ramb, cancfg and canctrl.init. canctrl.init should not be cleared until the channel has been disabled. the channel is dis- abled by writing the channel enable bit (ca nctrl.cen) to zero. wh en the channel enable status bit (cansr.cen) is zero, the channel has been disabled and canctrl.init can be written to zero. thereafter the channel can be restarted by writing a one to canctrl.cen. see figure 29-4 for details. it is not possible to write to other canctrl bits when canctrl.init is o ne. user must write a zero to canctrl.init before wr iting a new value to canctrl. figure 29-4. initialization sequence note: initialization requires all clocks to be running. 29.6.2.2 enabling / disabling a channel is enabled and ready to communicate on the bus when it has detected a bus idle con- dition (i.e. 11 consecutive recessive bits). the channel is enabled by writing a one to canctrl.cen and disabled by writing a zero to this bit. the enable status of channel can be read in cansr.ces bit. canctrl.init cansr.ces init. request (user write) canctrl.cen release init. (user write) restart (user write)
768 32117b?avr-03/11 at32uc3c the channel mode is not changed when the channel is disabled, i.e. the fault confinement reg- ister (canfc) is not cleared. therefore, if the channel was in error passive mode before being disabled, it stays in error passive mode when re-enabled. figure 29-5. enable and disable sequences 29.6.2.3 overload frames the can protocol allows nodes to send overload frames to provide extra delay between two messages. user can at any time request to send overload frames by writing the overload request bit (can- ctrl.ovrq) to one. a single ov erload frame will then be sent at the end of the next message. when transission of the overload frame star ts, cansr.ovs is set and canctrl.ovrq is cleared. at this time, user can write canctrl.ovrq to one again to send a second overload frame at the end of the first one. the can prot ocol specifies that maximum two overload frames can be sent. figure 29-6. overload frame request 29.6.2.4 errors and fault confinement this section refers to chapter 6 (error handling) and chapter 7 (fault confinement) of the can specification. there are 5 different error types which are not mutually exclusive. error status can be read in the interrupt status register (canisr). error st atus bits are set by hardware and can only be cleared by user. when the channel enters bus off state, the bus off status bit (canisr.boff) is set. in this state the channel can no longer communicate on the bus. the channel can leave bus off state if it detects 128 occurrences of 11 consecutive recessive bits on the bus. the last selected mob status field (canisr.lsmob) identifies the mob that was selected when the error occurred. for some error types, a mob has not been selected yet when the error occurs. in this case, canisr.lsmob returns none. cansr.ces enable request (user write) canctrl.cen disable request (user write) data frame can bus bus idle data frame overload frame 1 data or remote frame overload frame 2 can bus canctrl.ovrq cansr.ovs user write user write data or remote frame
769 32117b?avr-03/11 at32uc3c according to the can specification, a channel can be in error active, error passive or bus off state. the bus state can be read in the canfc.emode field: this state depends on both transmit and receive counters value (tec/rec), also available in the canfc register (see can specification for more details). 29.6.2.5 wake-up mode in this mode the can channel is a wake-up source for the cpu. detection of a falling edge on the can bus is interprete d as the start of frame (sof) bit of the wake-up frame and will wake the cpu. in order to use this mode, execute the following steps: ? disable can channel by writing canctrl.cen to zero ? wait for channel disabled (cansr.ces is cleared) ? enable wake-up mode by writing canctrl.wken to one ? optionally mask wake-up interrupt source by writing canimr.wkupim ? enter sleep mode, stopping pb and can clocks ?sleep ? wake-up frame is detected, canisr.wkup is set and cpu is woken-up ? clear canisr.wkup by writing it to zero ? disable wake-up mode and enable can channel note 1: when channel is disabled pb registers ar e not cleared, user can resume current applica- tion by enabling channel again. note 2: wake-up frame cannot be received. moreover next frames cannot be received until cpu is woken-up. wake-up time depends on sleep modes (see sleep modes section). 29.6.3 message handling 29.6.3.1 message object structure message objects (mob) are message descriptors, used to store and handle can frames. user configures and gets status of mobs via user interface registers and writing and reading frames into allocated ram space ( section 29.6.1.5 ). mobs are independent and are allocated to one channel. table 29-3. bus state coding emode state 0 error active state 1 error passive state 2 or 3 bus off state
770 32117b?avr-03/11 at32uc3c figure 29-7. message object structure where: ? rtr is the remote transmission request, 0 means data frame and 1 remote frame ? ide is the identifier extension bit, 0 means standard format and 1 means extended format ? id is the can identifier of message (11 bits in standard format and 29 bits in extended format) ? rtrm is the rtr bit mask ? idem is the ide bit mask ? idm are the id bits mask the length of the message (dlc) is stored in the mob control register (mobctrl). the data stored in ram should have the following format: figure 29-8. identifier tag (idt) rtr + ide + id (31 bits) status (4 bits) control (6 bits) rtrm + idem + idm (31 bits) data bytes (64 bits) registers (pb) ram (hsb) mob(i) mobctrl mobscr/ mobsr idt idm data[31:0] data[63:32] - rtr ide id (29 bits) 29 30 31 28 0 - rtr ide - 29 30 31 28 0 id (11 bits) 10 11 standard format extended format
771 32117b?avr-03/11 at32uc3c figure 29-9. identifier mask (idm) figure 29-10. data fields (64 bits) 29.6.3.2 transmission once a message has been written into ram at the address corresponding to the selected mob, user controls transmission through the mobctrl register: ? dlc[3:0] field: data length code i.e. the number of byte to send, from 0 to 8 ? dir bit: mob direction, 1 stands for transmission once mob is enabled (by writing to mober), transm ission starts as soon as bus idle is detected on the can bus. user can check if channel is sending a frame by reading cansr.ts bit. at the end of the successful transmission bit mobesr.menn is cleared and mobsr.txok is set. to acknowledge interrupt and to free the mob user must clear this status bit by writing a one to the associated bit in mob status clear register (mobscr). can errors detected during tran smission are reported in canisr. message will not be transmit- ted but the mob remains enabled. the message will be automatically re-transmitted until successfully transmitted. several mobs can be enabled/disabled in one operation by writing to the mober/mobdr registers: ? mober: each bit correspond to an enable bit for a single mob. write 1 to set a bit and 0 to keep it unchanged. ? mobdr: each bit correspond to an enable bit for a single mob. write 1 to clear a bit and 0 to keep it unchanged. if several mobs are enabled, the mob with the lowest number is transmitted first. this rule is also used in case of a re-transmission (due to transmission error or contention). 29.6.3.3 reception once the expected message has been written into ram at the address corresponding to the selected mob, user controls reception through the mobctrl register: ? dlc[3:0] field: data length code i.e. the number of byte to receive, from 0 to 8 - idm (29 bits) 29 30 31 28 0 - - 29 30 31 28 0 idm (11 bits) 10 11 standard format extended format rtrm idem rtrm idem db3 db2 db1 db0 db7 db6 db5 db4 31 23 15 7 0 8 16 24 @ @+4
772 32117b?avr-03/11 at32uc3c ? dir bit: mob direction, 0 stands for reception once a mob is enabled (by writing to mober), an incoming frame is compared ( section 29.6.4 ) with every mob enabled for reception in order to select the mob for storing the frame. user can check if the channel is receiving a frame by reading the cansr.rs bit. at the end of the successful reception, the complete message (id + rtr + ide + data bits) is stored in ram, the mobesr.menn bit is cl eared and mobsr.rxok is set. to acknowledge any interrupt and to free the mob user must clear this status bit by writing a one to the associ- ated bit in mobscr. the mobsr.dlcw bit indicates if the received dlc does not correspond to mobctrl.dlc. any such status should also be cleared by user. can errors detected during reception are reported in canisr register. a corrupted message is not stored to ram but the selected mob remains enabled. user can enable/disable several mobs in one operation, by writing to mober/mobdr registers ( section 29.6.3.2 ). if several mobs are enabled, the mob priority is given by the filtering order which is from low to high mob number. 29.6.3.4 automatic mode all mobs are configured in automatic mode if the automatic mode (mobctrl.am) bit is set. the main configurations are: ? remote frame reception - data frame transmission mob configuration: mobctrl.am = 1, mobctrl.dir = 0, idt.rtr = 1 idt/idm can be set to receive any identifier but transmission will be done with identifier received. ? remote frame transmission - data frame reception mob configuration: mobctrl.am = 1, mobctrl.dir = 1, idt.rtr = 1 remote frame is sent with idt value. reception uses current idt value but idm can be set to filter data frame. other configurations (idt.rtr = 0) are possible but does not make sense. properties: ? mob handling is identical to single configuration (priority, access,...) but: ? bits mobctrl.am and idt.rtr are inverted at the end of first reception/transmission ? bit mobsr.txok (or rxok) is only set at the end of the transmission (or reception) 29.6.4 message filtering the filtering process uses the id tag (idt) and id mask (idm) values defined in ram. compari- son is done on the bits identifier, rtr and ide. messages can therefore be filtered according to the identifier value, frame type (remote or data frame) and the format (standard or extended). each received bit is compared with the corresponding bit in the id tag only if the corresponding bit in id mask is set. otherwise th e received bit is considered as don?t care. the filtering result is true if all comparisons are true. examples with 11 bits of identifier ( ?-? means don?t care):
773 32117b?avr-03/11 at32uc3c id received: 000.0010.1001 b 000.0010.1001 b idt: 000.0010.1010 b 000.0100.1000 b idm: 111.1111.0000 b 111.1111.0000 b comparison: 111.1111.- - - - b 111.1001.- - - - b accepted: y n the filtering process scans each mob enabled and configured for reception, from mob 0, in order to find the mob that matches the conditions. the first mob to match is selected for storing the message once received successfully. if no mob matches, the message is discarded. 29.6.5 channel interrupts there are several sources of interrupts and user can mask each of them. some sources are grouped into a single interrupt request line. there are 5 interrupt request lines per channel. ? wake-up interrupt: wake-up condition detected ? error interrupt: any can error detected during a communication ? bus off interrupt: the can protocol engine entered in bus off state ? took interrupt: at least one mob completed a transmission ? waxed interrupt: at least one mob completed a reception the canimr and mobimr are used for masking interrupts. these registers are read-only. in order to set or clear interrupt mask bits, user must write to the following registers: ? canier / mobier: writing a bit to one sets the corresponding bit in canimr / mobimr. writing a bit to 0 has no effect. ? canidr / mobidr: writing a bit to one clears the corresponding bit in canimr / mobimr. writing a bit to 0 has no effect. to acknowledge an interrupt request, user must clear the corresponding bit in the corresponding status register (canisr, mtxisr or mrxisr). to clear status bits, user must access the fol- lowing write-only registers: ? caniscr / mtxiscr / mrxiscr: writing a bit to one clears the corresponding bit in canisr / mtxisr / mrxisr. writing a bit to 0 has no effect. for each mob, the bits txok and rxok are also accessible in mobscr register for clear access and mobsr regist er for read access.
774 32117b?avr-03/11 at32uc3c figure 29-11. interrupt channel structure or txoki txok0 mtxisr mim0 mobimr mimi ... ... . . . . . . or rxoki rxok0 mrxisr ... . . . . . . canimr txokim rxokim txok irq rxok irq canimr wkupim wkup canisr aerr ferr cerr serr berr boff or berri m boffim wake-up irq error irq bus off irq serrim cerri m ferrim aerrim
775 32117b?avr-03/11 at32uc3c 29.7 user interface offsets are relative to the base address allocated to canif and the channel number. figure 29-12. address map overview id idm data[31:0] data[63:32] id idm data[31:0] data[63:32] ram space id cancfg mobctrl mobscr mob0 mobctrl mobscr mob(i) 0x4 0x8 0xc 0x10 0x14 0x18 0x1c (i*0x10) offset idm ... (i*0x10)+0x4 ... (i*0x10)+0x8 canramb ... mtxisr ... 0x0 offset 0x0c 0x08 0x58 0x5c 0x60 (i*0xc)+0x5c pb registers mobsr 0x64 mobsr parameter version 0x00 0x04 (i*0xc)+0x60 (i*0xc)+0x64 ... cancfg canramb mtxisr ... 0x20c 0x208 0x258 ... channel 0 channel 1 common registers mob0 mob1 mob(i) table 29-4. canif register memory map offset register register name access reset 0x00 version register version read-only - (note:) 0x04 parameter register parameter read-only - (note:) 0x08 ram base address register canramb read/write 0x00000000 0x0c configuration regist er cancfg read/write 0x00000001 0x10 control register canctrl read/write 0x00000000 0x14 status register cansr read-only 0x00000000 0x18 fault confinement register canfc read-only 0x00000000 0x1c interrupt enable register canier write-only 0x00000000 0x20 interrupt disable register canidr write-only 0x00000000
776 32117b?avr-03/11 at32uc3c note: the reset values for these registers are device specific. pl ease refer to the module configuration section at the end of t his chapter. 0x24 interrupt mask register canimr read-only 0x00000000 0x28 interrupt status clear register caniscr write-only 0x00200000 0x2c interrupt status register canisr read-only 0x00200000 0x30 mob search register mobsch read-only 0x00202020 0x34 mob enable register mober write-only 0x00000000 0x38 mob disable register mobdr write-only 0x00000000 0x3c mob enable status regi ster mobesr read-only 0x00000000 0x40 mob interrupt enable regi ster mobier write-only 0x00000000 0x44 mob interrupt disable register mobidr write-only 0x00000000 0x48 mob interrupt mask register mobimr read-only 0x00000000 0x4c mob rx interrupt status clear register mrxiscr write-only 0x00000000 0x50 mob rx interrupt status re gister mrxisr read-only 0x00000000 0x54 mob tx interrupt st atus clear register mtxiscr write-only 0x00000000 0x58 mob tx interrupt status r egister mtxisr read-only 0x00000000 0x5c mob control register mobctrl read/write 0x00000000 0x60 mob status clear register mobscr write-only 0x00000000 0x64 mob status register mobsr read-only 0x00000000 table 29-4. canif register memory map
777 32117b?avr-03/11 at32uc3c 29.7.1 version register name : version access type: read-only offset: 0x00 reset value: - ? mnch0: mob number channel #0 number of mob for channel 0 (1..32). ? chno: channel number number of can channels (1..5). ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 - - mnch0 23 22 21 20 19 18 17 16 - chno variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
778 32117b?avr-03/11 at32uc3c 29.7.2 parameter register name : parameter access type: read-only offset: 0x04 reset value: - ? mnch4: mob number channel #4 number of mob for channel 4 (0..32). ? mnch3: mob number channel #3 number of mob for channel 3 (0..32). ? mnch2: mob number channel #2 number of mob for channel 2 (0..32). ? mnch1: mob number channel #1 number of mob for channel 1 (0..32). 31 30 29 28 27 26 25 24 - - mnch4 23 22 21 20 19 18 17 16 - - mnch3 15 14 13 12 11 10 9 8 - - mnch2 76543210 - - mnch1
779 32117b?avr-03/11 at32uc3c 29.7.3 ram base address register name :canramb access type: read/write offset: 0x08 reset value: 0x00000000 ? rambase: ram base address can channel ram base address. 31 30 29 28 27 26 25 24 rambase[31:24] 23 22 21 20 19 18 17 16 rambase[23:16] 15 14 13 12 11 10 9 8 rambase[15:8] 76543210 rambase[7:0]
780 32117b?avr-03/11 at32uc3c 29.7.4 configuration register name :cancfg access type: read/write offset: 0x0c reset value: 0x00000001 ? ovrm: overrun mode overrun mode (mob is not disabled after successful reception, therefore overwrite is possible). ? cmode: channel mode 00: normal mode. 01: listening mode. 10: loop back mode. ? sm: sampli ng method 0: once. 1: three times. ? sjw: synchronization jump width maximum number of time quanta for resynchronization. ? prs: propagation segment number of time quanta for propagation segment. ? phs2: phase segment 2 number of time quanta for phase segment 2. ? phs1: phase segment 1 number of time quanta for phase segment 1. ? pres: prescaler can clock prescaler. defines time quantum duration. should not be set to 0. 31 30 29 28 27 26 25 24 -----ovrm cmode 23 22 21 20 19 18 17 16 --sm sjw prs 15 14 13 12 11 10 9 8 - - phs2 phs1 76543210 - - pres
781 32117b?avr-03/11 at32uc3c 29.7.5 control register name :canctrl access type: read/write offset: 0x10 reset value: 0x00000000 ? wken: wake-up enable 0: wake-up mode disabled. 1: wake-up mode enabled, any bus activity will set canisr.wkup. ? ovrq: overload request 0: no overload frame request pending. 1: overload frame request pending, overload frame will be sent at the end of next received frame. ? cen: channel enable 0: no can channel enable request pending. 1: can channel enable request pending. ? init: initialization 0: can channel not initialized. 1: initialize can channel. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - wken ovrq cen init
782 32117b?avr-03/11 at32uc3c 29.7.6 status register name :cansr access type: read-only offset: 0x14 reset value: 0x00000000 ? rs: reception status 0: no frame is being received 1: frame is being received ? ts: transmission status 0: no frame is being transmitted 1: frame is being transmitted ? ovs: overload status 0: no overload frame is being transmitted 1: overload frame is being transmitted ? ces: channel enable status 0: channel disabled 1: channel ready 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ----rstsovsces
783 32117b?avr-03/11 at32uc3c 29.7.7 fault confinement register name :canfc access type: read-only offset: 0x18 reset value: 0x00000000 ? emode: error mode 00: error active 01: error passive 1x: bus off ? tec: transmit error counter ? rec: reception error counter 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------ emode 15 14 13 12 11 10 9 8 tec 76543210 rec
784 32117b?avr-03/11 at32uc3c 29.7.8 interrupt enable register name :canier access type: write-only offset: 0x1c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------txokim 76543210 rxokim wkupim berrim serrim c errim ferrim aerrim boffim
785 32117b?avr-03/11 at32uc3c 29.7.9 interrupt disable register name :canidr access type: write-only offset: 0x20 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------txokim 76543210 rxokim wkupim berrim serrim c errim ferrim aerrim boffim
786 32117b?avr-03/11 at32uc3c 29.7.10 interrupt mask register name :canimr access type: read-only offset: 0x24 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------txokim 76543210 rxokim wkupim berrim serrim c errim ferrim aerrim boffim
787 32117b?avr-03/11 at32uc3c 29.7.11 interrupt status clear register name :caniscr access type: write-only offset: 0x28 reset value: 0x00200000 ? lsmob: last selected mob status clear write all bits to one to clear last selected mob number. writing these bits to any other value has no effect. ? wkup: wake-up status clear write to one to clear wake-up status. writing this bit to zero has no effect. ? berr: bit error status clear write to one to clear bit error status. writing this bit to zero has no effect. ? serr: stuff error status clear write to one to clear stuffing error status. writing this bit to zero has no effect. ? cerr: crc error status clear write to one to clea r crc error status. writing this bit to zero has no effect. ? ferr: form error status clear write to one to clear form error status. writing this bit to zero has no effect. ? aerr: acknowledge error status clear write to one to clear acknowledge error status. writing this bit to zero has no effect. ? boff: bus off status clear write to one to clear bus off status. writing this bit to zero has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -- lsmob 15 14 13 12 11 10 9 8 -------- 76543210 - wkup berr serr cerr ferr aerr boff
788 32117b?avr-03/11 at32uc3c 29.7.12 interrupt status register name :canisr access type: read-only offset: 0x2c reset value: 0x00200000 ? lsmob: last selected mob status last selected mob number (1x: none, 0x: mob x selected). ? wkup: wake-up status 0: no wake-up request detected. 1: wake-up request (bus activity detected while canctrl.wken=1). ? berr: bit error status 0: no bit error detected in current frame. 1: bit error detected in current frame. ? serr: stuff error status 0: no stuffing error detected in current frame. 1: stuffing error detected in current frame. ? cerr: crc error status 0: no crc error detected in current frame. 1: crc error detected in current frame. ? ferr: form error status 0: no form error detected in current frame. 1: form error detected in current frame. ? aerr: acknowledge error status 0: no acknowledge error detected in current frame. 1: acknowledge error detected in current frame. ? boff: bus off status 0: can channel not in bus off state. 1: can channel switched to bus off state. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -- lsmob 15 14 13 12 11 10 9 8 -------- 76543210 - wkup berr serr cerr ferr aerr boff
789 32117b?avr-03/11 at32uc3c 29.7.13 mob search register name :mosch access type: read-only offset: 0x30 reset value: 0x00202020 ? mtxok: mob txok mob txok number, with highest priority 1xxxxx: no mob found 0xxxxx: mob x found ? mrxok: mob rxok mob rxok number, with highest priority 1xxxxx: no mob found 0xxxxx: mob x found ? mav: mob available mob available number, with highest priority 1xxxxx: no mob found 0xxxxx: mob x found 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -- mtxok 15 14 13 12 11 10 9 8 -- mrxok 76543210 -- mav
790 32117b?avr-03/11 at32uc3c 29.7.14 mob enable register name : mober access type: write-only offset: 0x34 reset value: 0x00000000 ? men: mob enable writing a bit to zero has no effect. writing a bit to one will enable the corresponding mob. 31 30 29 28 27 26 25 24 men[31:24] 23 22 21 20 19 18 17 16 men[23:16] 15 14 13 12 11 10 9 8 men[15:8] 76543210 men[7:0]
791 32117b?avr-03/11 at32uc3c 29.7.15 mob disable register name :mobdr access type: write-only offset: 0x38 reset value: 0x00000000 ?mdis: mob disable writing a bit to zero has no effect. writing a bit to one will disable the corresponding mob. 31 30 29 28 27 26 25 24 mdis[31:24] 23 22 21 20 19 18 17 16 mdis[23:16] 15 14 13 12 11 10 9 8 mdis[15:8] 76543210 mdis[7:0]
792 32117b?avr-03/11 at32uc3c 29.7.16 mob enable status register name : mobesr access type: read-only offset: 0x3c reset value: 0x00000000 ? men: mob enable 0: the corresponding mob is disabled 1: the corresponding mob is enabled this bit is cleared when the corresponding bit in mobdr is written to one. this bit is set when the corresponding bit in mober is written to one. 31 30 29 28 27 26 25 24 men[31:24] 23 22 21 20 19 18 17 16 men[23:16] 15 14 13 12 11 10 9 8 men[15:8] 76543210 men[7:0]
793 32117b?avr-03/11 at32uc3c 29.7.17 mob interrupt enable register name :mobier access type: write-only offset: 0x40 reset value: 0x00000000 ? mim: mob interrupt mask writing a bit to zero has no effect. writing a bit to one will set the corresponding bit in mobimr. 31 30 29 28 27 26 25 24 mim[31:24] 23 22 21 20 19 18 17 16 mim[23:16] 15 14 13 12 11 10 9 8 mim[15:8] 76543210 mim[7:0]
794 32117b?avr-03/11 at32uc3c 29.7.18 mob interrupt disable register name :mobidr access type: write-only offset: 0x44 reset value: 0x00000000 ? mim: mob interrupt mask writing a bit to zero has no effect. writing a bit to one will set the corresponding bit in mobimr. 31 30 29 28 27 26 25 24 mim[31:24] 23 22 21 20 19 18 17 16 mim[23:16] 15 14 13 12 11 10 9 8 mim[15:8] 76543210 mim[7:0]
795 32117b?avr-03/11 at32uc3c 29.7.19 mob interrupt mask register name :mobimr access type: read-only offset: 0x48 reset value: 0x00000000 ? mim: mob interrupt mask 0: the corresponding mob interrupt is disabled. 1: the corresponding mob interrupt is enabled. this bit is cleared when the corresponding bit in mobidr is written to one. this bit is set when the corresponding bit in mobier is written to one. 31 30 29 28 27 26 25 24 mim[31:24] 23 22 21 20 19 18 17 16 mim[23:16] 15 14 13 12 11 10 9 8 mim[15:8] 76543210 mim[7:0]
796 32117b?avr-03/11 at32uc3c 29.7.20 mob rx interrupt status clear register name :mrxiscr access type: write-only offset: 0x4c reset value: 0x00000000 ? rxok: reception successful writing a bit to zero has no effect. writing a bit to one will clear the corresponding bit in mrxisr. 31 30 29 28 27 26 25 24 rxok[31:24] 23 22 21 20 19 18 17 16 rxok[23:16] 15 14 13 12 11 10 9 8 rxok[15:8] 76543210 rxok[7:0]
797 32117b?avr-03/11 at32uc3c 29.7.21 mob rx interrupt status register name :mrxisr access type: read-only offset: 0x50 reset value: 0x00000000 ? rxok: reception successful 0: the corresponding mob has not completed a reception. 1: the corresponding mob has completed a reception (same bit as mobsrn.rxok). this bit is cleared when the corresponding bit in mrxiscr is written to one. this bit is set when the corresponding mob has completed a reception. 31 30 29 28 27 26 25 24 rxok[31:24] 23 22 21 20 19 18 17 16 rxok[23:16] 15 14 13 12 11 10 9 8 rxok[15:8] 76543210 rxok[7:0]
798 32117b?avr-03/11 at32uc3c 29.7.22 mob tx interrupt status clear register name :mtxiscr access type: write-only offset: 0x54 reset value: 0x00000000 ? txok: transmission successful writing a bit to zero has no effect. writing a bit to one will clear the corresponding bit in mtxisr. 31 30 29 28 27 26 25 24 txok[31:24] 23 22 21 20 19 18 17 16 txok[23:16] 15 14 13 12 11 10 9 8 txok[15:8] 76543210 txok[7:0]
799 32117b?avr-03/11 at32uc3c 29.7.23 mob tx interrupt status register name :mtxisr access type: read-only offset: 0x58 reset value: 0x00000000 ? txok: transmission successful 0: the corresponding mob has not completed a transmission. 1: the corresponding mob has completed a transmission (same bit as mobsrn.txok). this bit is cleared when the correspondi ng bit in mtxiscr is written to one. this bit is set when the corresponding mob has completed a transmission. 31 30 29 28 27 26 25 24 txok[31:24] 23 22 21 20 19 18 17 16 txok[23:16] 15 14 13 12 11 10 9 8 txok[15:8] 76543210 txok[7:0]
800 32117b?avr-03/11 at32uc3c 29.7.24 mob control register name : mobctrln access type: read/write offset: 0x5c + [n * 0xc] reset value: 0x00000000 ? am: automatic mode 0: automatic transmit mode 1: automatic receive mode ? dir: transfer direction 0: reception 1: transmission ? dlc: data length code valid data length code is from 0 to 8. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --amdir dlc
801 32117b?avr-03/11 at32uc3c 29.7.25 mob status clear register name : mobscrn access type: write-only offset: 0x60 + [n * 0xc] reset value: 0x00000000 ? ovw: overwrite writing this bit to zero has no effect. writing this bit to one clears the ovw status in mobsr. ? dlcw: dlc warning writing this bit to zero has no effect. writing this bit to one clears dlcw status in mobsr. ? txok: transmission successful writing this bit to zero has no effect. writing this bit to one clears txok status in mobsr. ? rxok: reception successful writing this bit to zero has no effect. writing this bit to one clears rxok status in mobsr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - ovw dlcw txok rxok
802 32117b?avr-03/11 at32uc3c 29.7.26 mob status register name : mobsrn access type: read-only offset: 0x64 + [n * 0xc] reset value: 0x00000000 ? ovw: overwrite 0: previous message has not been overwritten. 1: a new message has been received and overwr itten previous one (if cancfg.ovrm is set). ? dlcw: dlc warning 0: received dlc matches mobctrl.dlc. 1: received dlc is different from mobctrl.dlc. ? txok: transmission successful 0: transmission not completed or not successful. 1: transmission completed and successful. ? rxok: reception successful 0: reception not comple ted or not successful. 1: reception completed and successful. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - ovw dlcw txok rxok
803 32117b?avr-03/11 at32uc3c 29.8 module configuration the specific configuration for each canif instanc e is listed in the following tables. the module bus clocks listed here are conn ected to the system bus clocks. refer to the power manager chapter for details. table 29-5. module configuration feature canif canif channels 2 table 29-6. module clock name module name clock name description canif clk_canif_hsb hsb clock clk_canif_pb peripheral bus clock from the pbc clock domain gclk the generic clock used for the canif is gclk1 table 29-7. register reset values register reset value version 0x10200110 parameter 0x00000010
804 32117b?avr-03/11 at32uc3c 30. inter-ic sound controller (iisc) rev.: 2.0.0.0 30.1 features ? compliant with inter-ic sound (i 2 s) bus specification ? master, slave, and controller modes: ? slave: data received/transmitted ? master: data received/transmitted and clocks generated ? controller: clocks generated ? individual enable and disable of receiver, transmitter, and clocks ? configurable clock generator comm on to receiver and transmitter: ? suitable for a wide range of sample frequenc ies (fs), including 32khz, 44.1khz, 48khz, 88.2khz, 96khz, and 192khz ? 16fs to 1024fs master clock generated for external oversampling adcs ? several data formats supported: ? 32-, 24-, 20-, 18-, 16-, and 8-bit mono or stereo format ? 16- and 8-bit compact stereo format, with left and right samples packed in the same word to reduce data transfers ? several data frame formats supported: ? 2-channel i 2 s with word select ? 1- to 8-channel time division multiplexed (tdm) with frame sync ? dma interfaces for receiver and transmit ter to reduce processor overhead: ? either one dma channel for all audio channels, or ? one dma channel per audio channel ? smart holding registers management to avoid audio channels mix after overrun or underrun 30.2 overview the inter-ic sound controller (iisc) provides a 5-wire, bidirectional, synchronous, digital audio link with external audio devices: isdi , isdo, iws, isck, and imck pins. this controller is compliant with the inter-ic sound (i 2 s) bus specification and supports tdm interface with external mu lti-channel audio codecs. the iisc consists of a receiver, a transmitter, and a common clock generator, that can be enabled separately, to provide master, slave, or controller modes with receiver, transmitter, or both active. peripheral dma channels, separate for the receiver and for the transmitter, allow a continuous high bitrate data transfer without processor intervention to the following: ? audio codecs in master, slave, or controller mode ? stereo dac or adc through dedicated i 2 s serial interface ? multi-channel or multiple stereo dacs or adcs, using the tdm format the iisc can use either a single dma channel for all audio channels or one dma channel per audio channel. the 8- and 16-bit compact stereo format allows reducing the required dma bandwidth by trans- ferring the left and right samples within the same data word. in master mode, the iisc allows outputting a 16 fs to 1024fs master clock, in order to provide an oversampling clock to an external audio codec or digital signal processor (dsp).
805 32117b?avr-03/11 at32uc3c 30.3 block diagram figure 30-1. iisc block diagram 30.4 i/o lines description 30.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 30.5.1 i/o lines the iisc pins may be multiplexed with i/o contro ller lines. the user must first program the i/o controller to assign the desired iisc pins to their peripheral function. if the iisc i/o lines are not used by the application, they can be used for other purposes by the i/o controller. it is required to enable only the iisc inputs and outputs actually in use. 30.5.2 power management if the cpu enters a sleep mode th at disables clocks used by the iisc, the iisc will stop function- ing and resume operation after the system wakes up from sleep mode. i/o controller isck iws isdi isdo imck receiver clocks transmitter peripheral bus interface generic clock pb peripheral bus bridge interrupt controller scif power manager pb clock irq peripheral dma controller rx tx iisc table 30-1. i/o lines description pin name pin description type imck master clock output isck serial clock input/output iws i 2 s word select or tdm frame sync input/output isdi serial data input input isdo serial data output output
806 32117b?avr-03/11 at32uc3c 30.5.3 clocks the clock for the iisc bus interface (clk_iisc) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to disable the iisc before disabling the clock, to avoid freezing the iisc in an undefined state. one of the generic clocks is connected to the iisc. the generic clock (gclk_iisc) can be set to a wide range of frequencies and clock sources. the gclk_iisc must be enabled and config- ured before use. refer to the module configuration section for details on the gclk_iisc used for the iisc. the frequency for this clock has to be set as described in table. 30.5.4 dma the iisc dma handshake interfaces are connected to the peripheral dma controller. using the iisc dma functionality requires the peripheral dma controller to be programmed first. 30.5.5 interrupts the iisc interrupt line is connected to the interrupt controller. using the iisc interrupt requires the interrupt controller to be programmed first. 30.5.6 debug operation when an external debugger forces the cpu into debug mode, the iisc continues normal opera- tion. if this module is configured in a way that requires it to be periodically serviced by the cpu through interrupt requests or similar, improper operation or data loss may result during debugging. 30.6 functional description 30.6.1 initialization the iisc features a receiver, a transmitter, and, for master and controller modes, a clock generator. receiver and transmitter share the same serial clock and word select. before enabling the iisc, the chosen configuration must be written to the mode register (mr). the imckmode, mode, format, and datalength fi elds in the mr register must be writ- ten. if format is configured in one of t he tdm formats, then the nbchan and tdmfs fields must also be written. if the imckmode field is written as one, then the imckfs field should be written with the chosen ratio, as described in section 30.6.6 ?serial clo ck and word select gen- eration? on page 808 . once the mode register has been written, t he iisc clock generator, receiver, and transmitter can be enabled by writing a one to the cken, rx en, and txen bits in the control register (cr). the clock generator can be enabled alone, in controller mode, to output clocks to the imck, isck, and iws pins. the clock generator must also be enabled if the receiver or the transmitter is enabled. the clock generator, receiver, and transmitter can be disabled independently by writing a one to cr.cxdis, cr.rxdis and/or cr.txdis respec tively. once requested to stop, they will only stop when the transmission of the p ending frame transmi ssion will be completed. 30.6.2 basic operation the receiver can be operated by reading the receiver holding regist er (rhr), whenever the receive ready (rxrdy) bit in the status regist er (sr) is set. successive values read from rhr will correspond to the samples from the le ft and right audio channel s, or from channels 0 to mr.nbchan in tdm mode, for the successive frames.
807 32117b?avr-03/11 at32uc3c the transmitter can be operated by writing to t he transmitter holding register (rhr), when- ever the transmit ready (txrdy) bit in the stat us register (sr) is set. successive values written to thr should correspond to the samples from the left and right audio channels, or from channels 0 to mr.nbchan in tdm mode, for the successive frames. the receive ready and transmit ready bits ca n be polled by reading the status register. the iisc processor load can be reduced by enabling interrupt-driven operation. the rxrdy and/or txrdy interrupt requests can be enabled by writing a one to the corresponding bit in the interrupt enable register (ier). the interrupt service routine associated to the iisc interrupt request will then be executed whenever the receiv e ready or the transmit ready status bit is set. 30.6.3 master, controller, and slave modes in master and controller modes, the iisc provi des the master clock, the serial clock and the word select. imck, isck, and iws pins are outputs. in controller mode, the iisc receiver and transmitter are disabled. only the clocks are enabled and used by an external receiver and/or transmitter. in slave mode, the iisc receives the serial clock and the word select from an external master. isck and iws pins are inputs. the mode is selected by writing the mode field of the mode register (mr). since the mode field changes the direction of the iws and isck pi ns, the mode register sh ould only be written when the iisc is stopped, in order to avoid unwanted glitches on the iws and isck pins. 30.6.4 i 2 s reception and transmission sequence as specified in the i 2 s protocol, data bits are left-adjusted in the word select time slot, with the msb transmitted first, starting one clock period after the transition on the word select line. figure 30-2. i 2 s reception and transmission sequence data bits are sent on the falling edge of the se rial clock and sampled on the rising edge of the serial clock. the word select line indicates t he channel in transmission, a low level for the left channel and a high level for the right channel. the length of transmitted words can be chosen among 8, 16, 18, 20, 24, and 32 bits by writing the mr.datalength field. if the time slot allows for more data bits t han written in the mr.datalength field, zeroes are appended to the transmitted data word or extra received bits are discarded. if the time slot allows for less data bits than written, the extra bits to be transmitted are not sent or the missing bits are set to zero in the received data word. serial clock isck word select iws data isdi/isdo msb left channel lsb msb right channel
808 32117b?avr-03/11 at32uc3c 30.6.5 tdm reception and transmission sequence in time division multiplexed (tdm) format, 1 to 8 data words are sent or received within each frame, as in the i 2 s protocol, data bits are left-adjusted in the channel time slot, with the msb transmitted first, starting one clock period after the transition on the word select line. each time slot is 32-bit long. figure 30-3. tdm reception and transmission sequence data bits are sent on the falling edge of the se rial clock and sampled on the rising edge of the serial clock. the iws pin pr ovides a frame synchronization signal, starting one isck period before the msb of channel 0. the time division multip lexed (tdm) format is selected by writing a one to the mr.format field. the frame sync pulse can be either one isck period or one 32-bit time slot. this selection is done by writing the mr.tdmfs bit. the number of channels is selected by writing the mr.channels field. the length of transmitted words can be chosen among 8, 16, 18, 20, 24, and 32 bits by writing the mr.datalength field. if the time slot allows for more data bits than programmed in the mr.datalength field, zeroes are appended to the transmitted data word or extra received bits are discarded. if the time slot allows for less data bits than programmed, the extra bits to be transmitted are not sent or the missing bits are set to zero in the right-adjusted received data word. 30.6.6 serial clock and word select generation the generation of clocks in the iisc is described in figure 30-4 on page 810 . in slave mode, the serial clock and word select clock are driven by an external master. isck and iws pins are inputs and no generic clock is required by the iisc. in master mode, the user can configure the master clock, serial clock, and word select clock through the mode register (mr). imck, isck, and iws pins are outputs and a generic clock is used to derive the iisc clocks. audio codecs connected to the iisc pins may require a master clock signal with a frequency multiple of the audio sample frequency (fs), such as 256fs. when the iisc is in master mode, writing a one to mr.imckmode will output gclk_i isc as master clock to the imck pin, and will divide gclk_iisc to create the internal bit cl ock, output on the isck pin. the clock division factor is defined by writing to mr.imckfs and mr.datalength, as described ?imckfs: master clock to fs ratio? on page 816 . serial clock (isck) frame sync (iws) data (isdi/isdo) channel 0 msb lsb msb lsb msb lsb msb lsb channel 2 channel 1 channel 3
809 32117b?avr-03/11 at32uc3c the master clock (imck) frequency is 8*(nbchan+1)*(imckfs+1) times the sample fre- quency (fs), i.e. iws frequency. the serial clock (isck) frequency is (nbchan+1)*slot length times the sample frequency (fs), where slot length is defined in table 30-2 on page 809 . warning: mr.imckmode shou ld only be written as one if the master clock frequency is strictly higher than the serial clock. if a master clock output is not required, the gclk _iisc generic clock is used as isck, by writ- ing a zero to mr.imckmode. alternatively, if the frequency of the generic clock used is a multiple of the required isck frequency, the imck to isck divider can be used with the ratio defined by writing the mr.imckfs field. the iws pin is used as word select in i2s format and as frame synchronization in tdm format, as described in section 30.6.4 and section 30.6.5 respectively. table 30-2. slot length mr.datalength word length slot length 0 32 bits 32 1 24 bits 32 if mr.iws24 is zero 24 if mr.iws24 is one 2 20 bits 3 18 bits 4 16 bits 16 5 16 bits compact stereo 6 8 bits 8 7 8 bits compact stereo
810 32117b?avr-03/11 at32uc3c figure 30-4. iisc clocks generation 30.6.7 mono when the transmit mono (txmono) in the mode register is set, data written to the left channel is duplicated to the right output channel. in tdm mode with more than two channels, numbered from 0, data written to the even-numbered channels is duplicated to the following odd-numbered channel. when the receive mono (rxmono) in the mode r egister is set, data received from the left channel is duplicated to the right channel. in tdm mode with more than two channels, num- bered from 0, data received from the even-numbered channels is duplicated to the following odd-numbered channel. 30.6.8 holding registers the iisc user interface includes a receive holding register (rhr) and a transmit holding register (thr). rhr and thr are used to access audio samples for all audio channels. when a new data word is available in the rhr r egister, the receive ready bit (rxrdy) in the status register (sr) is set. readin g the rhr register will clear this bit. a receive overrun condition occurs if a new da ta word becomes available before the previous data word has been read from the rhr register. then, the receive overrun bit in the status register will be set and bit i of the rxorch field in the status register is set, where i is the cur- rent receive channel number. when the thr register is empty, the transmit ready bit (txrdy) in the status register (sr) is set. writing into the thr re gister will clear this bit. a transmit underrun condition occurs if a new data word needs to be transmitted before it has been written to the thr register. then, the transmit underrun bit in the status register will be mr.mode = slave clock divider mr.datalength gclk_iisc clock enable clock divider cr.cken/ckdis mr.imckmode mr.datalength mr.imckfs mr.imckmode 1 0 imck pin output clock enable cr.cken/ckdis internal bit clock isck pin input 1 0 isck pin output internal word clock iws pin input 1 0 iws pin output
811 32117b?avr-03/11 at32uc3c set and bit i of the txorch field in the status register is set, where i is the current transmit channel number. if the txsame bit in the mode register is zero, then a zero data word is trans- mitted in case of underrun. if mr.txsame is one, then the previous data word for the current transmit channel number is transmitted. data words are right-justified in the rhr and thr registers. for 16-bit compact stereo, the left sample uses bits 15 through 0 and the right sample uses bits 31 through 16 of the same data word. for 8-bit compact stereo, the left sample uses bits 7 through 0 and the right sample uses bits 15 through 8 of the same data word. 30.6.9 dma operation the receiver and the transmitter can each be connected either to one single peripheral dma channel or to one peripheral dma channel per data channel. this is selected by writing to the mr.rxdma and mr.txdma bits. if a single peri pheral dma channel is selected, all data sam- ples use iisc receiver or transmitter dma channel 0. the peripheral dma reads from the rhr register and writes to the rhr register for all audio channels, successively. the peripheral dma transfers may use 32-bit word , 16-bit halfword, or 8-bit byte according to the value of the mr.datalength field. 30.6.10 loop-back mode for debugging purposes, the iisc can be configured to loop back the transmitter to the receiver. writing a one to the mr.loop bit will in ternally connect isdo to isdi, so that the transmitted data is also received. writing a zero to mr.loop will restore the normal behavior with independent receiver and transmitter. as for other changes to the receiver or transmitter configuration, the iisc receiver and transmitter must be disabled before writing to the mr reg- ister to update mr.loop. 30.6.11 interrupts an iisc interrupt request can be triggered whenever one or several of the following bits are set in the status register (sr) : receive ready (rxrdy), rece ive overrun (rxor), transmit ready (txrdy), or transmit underrun (txor). the interrupt request will be generated if the corresponding bit in the interrupt mask register (imr) is set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier), and cleared by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt request remains acti ve until the corresponding bit in sr is cleared by writing a one the corresponding bit in the status clear register (scr). for debugging purposes, interrupt requests can be simulated by writing a one to the correspond- ing bit in the status set register (ssr).
812 32117b?avr-03/11 at32uc3c figure 30-5. interrupt block diagram 30.7 iisc application examples the iisc can support several serial communica tion modes used in audio or high-speed serial links. some standard applications are shown in t he following figures. all se rial link applications supported by the iisc are not listed here. figure 30-6. audio application block diagram imr ier idr clear set interrupt control iisc interrupt request txrdy txur transmitter receiver rxrdy rxor serial clock word select serial data out msb lsb msb serial data out word select serial clock iisc isck iws isdo isdi external i 2 s receiver
813 32117b?avr-03/11 at32uc3c figure 30-7. codec application block diagram figure 30-8. time slot application block diagram iisc frame sync serial data out serial data in serial clock frame sync serial data out serial data in dstart dend first time slot external audio codec imck iws isdo isdi serial clock master clock isck external audio codec for first time slot external audio codec for second time slot serial data in serial data out frame sync serial clock serial clock frame sync serial data out serial data in dstart first time slot second time slot dend iisc isck iws isdo isdi master clock imck
814 32117b?avr-03/11 at32uc3c 30.8 user interface note: 1. the reset values for these registers are device specific. please refer to the module configuration section at the end of this chapter. table 30-3. iisc register memory map offset register register name access reset 0x00 control register cr write-only 0x00000000 0x04 mode register mr read/write 0x00000000 0x08 status register sr read-only 0x00000000 0x0c status clear register scr write-only 0x00000000 0x10 status set register ssr write-only 0x00000000 0x14 interrupt enable register ier write-only 0x00000000 0x18 interrupt disable register idr write-only 0x00000000 0x1c interrupt mask register imr read-only 0x00000000 0x20 receiver holding register rhr read-only 0x00000000 0x24 transmitter holding register thr write-only 0x00000000 0x28 version register version read-only - (1) 0x2c parameter register pa r a m e t e r read-only - (1)
815 32117b?avr-03/11 at32uc3c 30.8.1 control register name: cr access type: write-only offset: 0x00 reset value: 0x00000000 the control register should only be written to enable the iisc after the chosen configuration has been written to the mode register, in order to avoid unwanted glitches on the iws, isck, and isdo outputs. the proper sequence is to write the mr register, then write the cr register to enable the iisc, or to disable the iisc before writing a new value into mr. ? swrst: software reset writing a zero to this bit has no effect. writing a one to this bit resets all the registers in the module. the module will be disabled after the reset. this bit always reads as zero. ? txdis: transmitter disable writing a zero to this bit has no effect. writing a one to this bit disables the iisc transmitter. sr.txen will be cleared when the transmitter is effectively stopped. ? txen: transmitter enable writing a zero to this bit has no effect. writing a one to this bit enables the iisc transmitter, if tx dis is not one. sr.txen will be set when the transmitter is effect ively started. ? ckdis: clocks disable writing a zero to this bit has no effect. writing a one to this bit disables the iisc clocks generation. ? cken: clocks enable writing a zero to this bit has no effect. writing a one to this bit enables the iisc clocks generation, if ckdis is not one. ? rxdis: receiver disable writing a zero to this bit has no effect. writing a one to this bit disables the iisc receiver. sr.txe n will be cleared when the transmitter is effectively stopped. ? rxen: receiver enable writing a zero to this bit has no effect. writing a one to this bit enables the iisc receiver, if rxdis is not one. sr.rxen will be set when the receiver is effectively started. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 swrst - txdis txen ckdis cken rxdis rxen
816 32117b?avr-03/11 at32uc3c 30.8.2 mode register name: mr access type: read/write offset: 0x04 reset value: 0x00000000 the mode register should only be written when the iisc is stopped, in order to avoid unwanted glitches on the iws, isck, and isdo outputs. the proper sequence is to write the mr register, then write the cr register to enable the iisc, or to dis- able the iisc before writing a new value into mr. ? iws24: iws tdm slot width 0: iws slot is 32-bit wide for datalength=18/20/24-bit 1: iws slot is 24-bit wide for datalength=18/20/24-bit refer to table 30-2, ?slot length,? on page 809 . ? imckmode: master clock mode 0: no master clock generated (gener ic clock is used as isck output) 1: master clock generated (generi c clock is used as imck output) warning: if imck frequency is the same as isck, imckmode should not be written as one. refer to section 30.6.6 ?serial clock and word select generation? on page 808 and table 30-2, ?slot length,? on page 809 . ? imckfs: master clock to fs ratio master clock frequency is 8*(nbchan+1)*(imckfs+1 ) times the sample rate, i.e. iws frequency: 31 30 29 28 27 26 25 24 iws24 imckmode imckfs 23 22 21 20 19 18 17 16 tdmfs - - - nbchan 15 14 13 12 11 10 9 8 - txsame txdma txmono rxloop rxdma rxmono 76543210 f o r m at - data l e n g t h - m o d e table 30-4. master clock to sampli ng frequency (fs) ratio fs ratio imckfs 2 channels 4 channels 6 channels 8 channels 16 fs 0 - - - 32 fs 1 0 - - 48fs2-0- 64 fs 3 1 - 0 96fs 5 2 1 - 128 fs 7 3 - 1 192fs 11 5 3 2
817 32117b?avr-03/11 at32uc3c ? tdmfs: tdm frame sync ? nbchan: number of tdm channels - 1 this field should be written with the number of tdm channels minus one ? txsame: transmit data when underrun 0: zero sample transmitted when underrun 1: previous sample transmitted when underrun (in i2s mode only) ? txdma: single or multiple dma channels for transmitter 0: transmitter uses a single dma channel for all audio channels 1: transmitter uses one dma channel per audio channel ? txmono: transmit mono 0: stereo 1: mono, with left audio samples duplicated to right audio channel by the iisc ? rxloop: loop-back test mode 0: normal mode 1: isdo output of iisc is inte rnally connected to isdi input ? rxmono: receive mono 0: stereo 1: mono, with left audio samples duplicated to right audio channel by the iisc ? rxdma: single or multiple dma channels for receiver 0: receiver uses a single dma channel for all audio channels 1: receiver uses one dma channel per audio channel- 256 fs 15 7 - 3 384 fs 23 11 7 5 512 fs 31 15 - 7 768 fs 47 23 15 11 1024 fs 63 31 - 15 table 30-5. tdm frame sync tdmfs description 0 slot iws pulse is high for one time slot at beginning of frame 1 half iws pulse is high for half the time slots at beginning of frame, i.e. half the iws period 3 bit iws pulse is high for one bit period at beginning of frame, i.e. one isck period 3- reserved table 30-4. master clock to sampli ng frequency (fs) ratio fs ratio imckfs 2 channels 4 channels 6 channels 8 channels
818 32117b?avr-03/11 at32uc3c ? format: i2s or tdm format ? datalength: data word length ?mode: mode table 30-6. frame format format description 0i2s i 2 s format, stereo with iws low for left channel, and msb of sample starting one isck period after iws edge 1 lj left-justified format, stereo with iws high for le ft channel, and msb of sample starting on iws edge 2tdm tdm format, with (nbchan+1) channels, iws high at beginning of first channel, and msb of sample starting one isck period after iws edge 3tdmlj tdm format, left-justified, with (nbchan+1) channels, iw s high at beginning of first channel, and msb of sample starting on iws edge table 30-7. data word length datalength word length comments 0 32 bits 1 24 bits 2 20 bits 3 18 bits 4 16 bits 5 16 bits compact stereo left sample in bits 15 through 0 and right sample in bits 31 through 16 of the same word 6 8 bits 7 8 bits compact stereo left sample in bits 7 through 0 and right sample in bits 15 through 8 of the same word table 30-8. mode mode comments 0 slave isck and iws pin inputs used as bit clock and word select/frame sync. 1 master bit clock and word select/frame sync generated by iisc from gclk_iisc and output to isck and iws pins. gclk_iisc is output as master clock on imck if mr.imckmode is one.
819 32117b?avr-03/11 at32uc3c 30.8.3 status register name: sr access type: read-only offset: 0x08 reset value: 0x00000000 ? txurch: transmit underrun channel this field is cleared when scr.txur is written to one bit i of this field is set when a transmit underrun error occurred in channel i (i=0 for first channel of the frame) ? rxorch: receive overrun channel this field is cleared when scr.rxor is written to one bit i of this field is set when a receive overrun error occurred in channel i (i=0 for first channel of the frame) ? txur: transmit underrun this bit is cleared when the corresponding bit in scr is written to one this bit is set when an underrun error occurs on the thr register or when the corresponding bit in ssr is written to one ? txrdy: transmit ready this bit is cleared when data is written to thr this bit is set when the thr register is empty and can be written with new data to be transmitted ? txen: transmitter enabled this bit is cleared when the transmitter is effectiv ely disabled, following a cr.txdis or cr.swrst request this bit is set when the transmitter is effectively enabled, following a cr.txen request ? rxor: receive overrun this bit is cleared when the corresponding bit in scr is written to one this bit is set when an overrun error occurs on the rhr register or when the corresponding bit in ssr is written to one ? rxrdy: receive ready this bit is cleared when the rhr register is read this bit is set when received data is present in the rhr register ? rxen: receiver enabled this bit is cleared when the receiver is effectivel y disabled, following a cr.rxdis or cr.swrst request this bit is set when the receiver is ef fectively enabled, following a cr.rxen request 31 30 29 28 27 26 25 24 ---- txurch[7:4] 23 22 21 20 19 18 17 16 txurch[3:0] - - - - 15 14 13 12 11 10 9 8 rxorch 76543210 - txur txrdy txen - rxor rxrdy rxen
820 32117b?avr-03/11 at32uc3c 30.8.4 status clear register name: scr access type: write-only offset: 0x0c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in sr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 ---- txurch[7:4] 23 22 21 20 19 18 17 16 txurch[3:0] - - - - 15 14 13 12 11 10 9 8 rxorch 76543210 -txur---rxor--
821 32117b?avr-03/11 at32uc3c 30.8.5 status set register name: ssr access type: write-only offset: 0x10 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in sr. 31 30 29 28 27 26 25 24 ---- txurch[7:4] 23 22 21 20 19 18 17 16 txurch[3:0] - - - - 15 14 13 12 11 10 9 8 rxorch 76543210 -txur---rxor--
822 32117b?avr-03/11 at32uc3c 30.8.6 interrupt enable register name: ier access type: write-only offset: 0x14 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - txur txrdy - - rxor rxrdy -
823 32117b?avr-03/11 at32uc3c 30.8.7 interrupt disable register name: idr access type: write-only offset: 0x18 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - txur txrdy - - rxor rxrdy -
824 32117b?avr-03/11 at32uc3c 30.8.8 interrupt mask register name: imr access type: read-only offset: 0x1c reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - txur txrdy - - rxor rxrdy -
825 32117b?avr-03/11 at32uc3c 30.8.9 receive holding register name: rhr access type: read-only offset: 0x20 reset value: 0x00000000 ? rhr: received word this field is set by hardware to the last received data word. if mr.datalength specifies less than 32 bits, data shall be right - justified into the rhr field. 31 30 29 28 27 26 25 24 rhr[31:24] 23 22 21 20 19 18 17 16 rhr[23:16] 15 14 13 12 11 10 9 8 rhr[15:8] 76543210 rhr[7:0]
826 32117b?avr-03/11 at32uc3c 30.8.10 transmit holding register name: thr access type: write-only offset: 0x24 reset value: 0x00000000 ? thr: data word to be transmitted next data word to be transmitted after the current word if txrd y is not set. if mr.datalength s pecifies less than 32 bits, data shall be right-justified into the thr field. 31 30 29 28 27 26 25 24 thr[31:24] 23 22 21 20 19 18 17 16 thr[23:16] 15 14 13 12 11 10 9 8 thr[15:8] 76543210 thr[7:0]
827 32117b?avr-03/11 at32uc3c 30.8.11 module version name: version access type: read-only offset: 0x28 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 ---- version[11:8] 76543210 version[7:0]
828 32117b?avr-03/11 at32uc3c 30.8.12 module parameters name: parameter access type: read-only offset: 0x2c reset value: - reserved. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
829 32117b?avr-03/11 at32uc3c 30.9 module configuration the specific configuration for each iisc instance is listed in the followin g tables. the module bus clocks listed here are connected to the system bus clocks according to the table in the system bus clock connections section. table 30-9. module configuration feature iisc number of tdm channels 8 channels number of peripheral dma channels 8 channels table 30-10. module clock name module name clock name clock name iisc clk_iisc peripheral bus clock from the pba clock domain gclk the generic clock used for the iisc is gclk11 table 30-11. register reset values register reset value version 0x00000200
830 32117b?avr-03/11 at32uc3c 31. timer/counter (tc) rev: 2.2.3.3 31.1 features ? three 16-bit timer counter channels ? a wide range of functions including: ? frequency measurement ? event counting ? interval measurement ? pulse generation ?delay timing ? pulse width modulation ? up/down capabilities ? each channel is user-conf igurable and contains: ? three external clock inputs ? five internal clock inputs ? two multi-purpose input/output signals ? internal interrupt signal ? two global registers that act on all three tc channels ? peripheral event input on al l a/b lines in capture mode 31.2 overview the timer counter (tc) includes three identical 16-bit timer counter channels. each channel can be independently programmed to perform a wide range of functions including frequency measurement, event counting, interval measurement, pulse generation, delay timing, and pulse width modulation. each channel has three external clock inputs, fi ve internal clock inputs, and two multi-purpose input/output signals which can be configured by the user. each channel drives an internal inter- rupt signal which can be programmed to generate processor interrupts. the tc block has two global registers which act upon all three tc channels. the block control register (bcr) allows the th ree channels to be started simultaneously with the same instruction. the block mode register (bmr) defines the ex ternal clock inputs for each channel, allowing them to be chained.
831 32117b?avr-03/11 at32uc3c 31.3 block diagram figure 31-1. tc block diagram 31.4 i/o lines description 31.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 31.5.1 i/o lines the pins used for interfacing the compliant external devices may be multiplexed with i/o lines. the user must first program the i/o controller to assign the tc pins to their peripheral functions. i/o co n t r o l l e r tc2xc2s int0 int1 int2 tioa0 tioa1 tioa2 tiob0 tiob1 tiob2 xc2 tclk0 tclk1 tclk2 tclk0 tclk1 tclk2 tclk0 tclk1 tclk2 tioa1 tioa2 tioa0 tioa2 tioa1 interrupt controller clk0 clk1 clk2 a0 b0 a1 b1 a2 b2 timer count er tiob tioa tiob sync timer_clock1 tioa sync sync tioa tiob timer_clock2 timer_clock3 timer_clock4 timer_clock5 xc1 xc0 xc0 xc2 xc1 xc0 xc1 xc2 timer/counter channel 2 timer/counter channel 1 timer/counter channel 0 tc1xc1s tc0xc0s tioa0 table 31-1. i/o lines description pin name description type clk0-clk2 external clock input input a0-a2 i/o line a input/output b0-b2 i/o line b input/output
832 32117b?avr-03/11 at32uc3c when using the tioa/tiob lines as inputs the us er must make sure that no peripheral events are generated on the line. refer to the peripheral event system chapter for details. 31.5.2 power management if the cpu enters a sleep mode that disables cl ocks used by the tc, the tc will stop functioning and resume operation after the system wakes up from sleep mode. 31.5.3 clocks the clock for the tc bus interface (clk_tc) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to disable the tc before disabling the clock, to avoid freezing the tc in an undefined state. 31.5.4 interrupts the tc interrupt request line is connected to the interrupt controller. using the tc interrupt requires the interrupt controller to be programmed first. 31.5.5 peripheral events the tc peripheral events are connected via the pe ripheral event system. refer to the periph- eral event system chapter for details. 31.5.6 debug operation the timer counter clocks are frozen du ring debug operation, unless the ocd system keeps peripherals running in debug operation. 31.6 functional description 31.6.1 tc description the three channels of the timer counter are independent and identical in operation. the regis- ters for channel programming are listed in figure 31-3 on page 847 . 31.6.1.1 channel i/o signals as described in figure 31-1 on page 831 , each channel has the following i/o signals. 31.6.1.2 16-bit counter each channel is organized around a 16-bit counter. the value of the counter is incremented at each positive edge of the selected clock. when the counter has reached the value 0xffff and passes to 0x0000, an overflow occurs and the counter overflow status bit in the channel n sta- tus register (srn.covfs) is set. table 31-2. channel i/o signals description block/channel sign al name description channel signal xc0, xc1, xc2 external clock inputs tioa capture mode: timer counter input waveform mode: timer counter output tiob capture mode: timer counter input waveform mode: timer counter input/output int interrupt signal output sync synchronization input signal
833 32117b?avr-03/11 at32uc3c the current value of the counter is accessible in real time by reading the channel n counter value register (cvn). the counter can be reset by a trigger. in this case, the counter value passes to 0x0000 on the next valid edge of the selected clock. 31.6.1.3 clock selection at block level, input clock signals of each channel can either be connected to the external inputs tclk0, tclk1 or tclk2, or be connected to the configurable i/o signals a0, a1 or a2 for chaining by writing to the bmr register. see figure 31-2 on page 833 . each channel can independently select an internal or external clock source for its counter: ? internal clock signals: timer_cl ock1, timer_clock2, timer_clock3, timer_clock4, timer_clock5. see the module configuration chapter for details about the connection of these clock sources. ? external clock signals: xc0, xc1 or xc2. see the module configuration chapter for details about the connection of these clock sources. this selection is made by the clock sele ction field in the channel n mode register (cmrn.tcclks). the selected clock can be inverted with the clock invert bit in cmrn (cmrn.clki). this allows counting on the opposite edges of the clock. the burst function allows the clock to be valida ted when an external signal is high. the burst signal selection field in the cmrn regi ster (cmrn.burst) defines this signal. note: in all cases, if an external clock is used, the du ration of each of its leve ls must be longer than the clk_tc period. the external clock frequency must be at least 2.5 times lower than the clk_tc. figure 31-2. clock selection timer_clock5 xc2 tcclks clki burst 1 selected clock xc1 xc0 timer_clock4 timer_clock3 timer_clock2 timer_clock1
834 32117b?avr-03/11 at32uc3c 31.6.1.4 clock control the clock of each counter can be controlled in two different ways: it can be enabled/disabled and started/stopped. see figure 31-3 on page 834 . ? the clock can be enabled or disabled by the user by writing to the counter clock enable/disable command bits in the channel n clock contro l register (ccrn.clken and ccrn.clkdis). in capture mode it can be disabled by an rb load event if the counter clock disable with rb loading bit in cmrn is written to one (cmrn.ldbdis). in waveform mode, it can be disabled by an rc compare event if the counter clock disable with rc compare bit in cmrn is written to one (cmrn.cpcdis). when disabled, the start or the stop actions have no effect: only a clken command in ccrn can re-enable the clock. when the clock is enabled, the clock enabling status bit is set in srn (srn.clksta). ? the clock can also be started or stopped: a trigger (software, synchro, external or compare) always starts the clock. in capture mode the clock can be stopped by an rb load event if the counter clock stopped with rb loading bit in cmrn is written to one (cmrn.ldbstop). in waveform mode it can be stopped by an rc compare event if the counter clock stopped with rc compare bit in cmrn is written to one (cmrn.cpcstop). the start and the stop commands have effect only if the clock is enabled. figure 31-3. clock control 31.6.1.5 tc operating modes each channel can independently operate in two different modes: ? capture mode provides measurement on signals. ? waveform mode provides wave generation. the tc operating mode selection is done by writing to the wave bit in the ccrn register (ccrn.wave). in capture mode, tioa and tiob are configured as inputs. qs r s r q clksta clken clkdis stop event disable counter clock selected clock trigger event
835 32117b?avr-03/11 at32uc3c in waveform mode, tioa is always configured to be an output and tiob is an output if it is not selected to be the external trigger. 31.6.1.6 trigger a trigger resets the counter and starts the counter clock. three types of triggers are common to both modes, and a fourth external trigger is available to each mode. the following triggers are common to both modes: ? software trigger: each channel has a software trigger, available by writing a one to the software trigger command bi t in ccrn (ccrn.swtrg). ? sync: each channel has a synchronization signal sync. when asserted, this signal has the same effect as a software trigger. the sync signals of all channels are asserted simultaneously by writing a one to the synchro command bit in the bcr register (bcr.sync). ? compare rc trigger: rc is implemented in each channel and can provide a trigger when the counter value matches the rc value if the rc compare trigger enable bit in cmrn (cmrn.cpctrg) is written to one. the channel can also be configured to have an external trigger. in capture mode, the external trigger signal can be selected between tioa and tiob. in waveform mode, an external event can be programmed to be one of the following si gnals: tiob, xc0, xc1, or xc2. this external event can then be programmed to perform a trigger by writing a one to the external event trig- ger enable bit in cmrn (cmrn.enetrg). if an external trigger is used, the duration of the pulses must be longer than the clk_tc period in order to be detected. regardless of the trigger used, it will be taken into account at the following active edge of the selected clock. this means that the counter value can be read differently from zero just after a trigger, especially when a low frequency signal is selected as the clock. 31.6.1.7 peripheral events on tioa/tiob inputs the tioa /tiob input lines are ored internally with peripheral events from the peripheral event system. to capture using events the user must ensure that the corresp onding pin functions for the tioa /tiob line are disabled. when capturing on the external tioa /tiob pin the user must ensure that no peripheral events are generated on this pin. 31.6.2 capture operating mode this mode is entered by writin g a zero to the cmrn.wave bit. capture mode allows the tc channel to perform measurements such as pulse timing, fre- quency, period, duty cycle and phase on tioa and tiob sig nals which are considered as inputs. figure 31-4 on page 837 shows the configuration of the tc channel when programmed in cap- ture mode. 31.6.2.1 capture registers a and b registers a and b (ra and rb) are used as capture registers. this means that they can be loaded with the counter value when a progr ammable event occurs on the signal tioa.
836 32117b?avr-03/11 at32uc3c the ra loading selection field in cmrn (cmrn.ldra) defines the tioa edge for the loading of the ra register, and the rb loading selection fi eld in cmrn (cmrn.ldrb) defines the tioa edge for the loading of the rb register. ra is loaded only if it has not been loaded since the last trigger or if rb has been loaded since the last loading of ra. rb is loaded only if ra has been loaded sinc e the last trigger or t he last loading of rb. loading ra or rb before the read of the last value loaded sets the load overrun status bit in srn (srn.lovrs). in this case, the old value is overwritten. 31.6.2.2 trigger conditions in addition to the sync signal, the software trigger and the rc compare trigger, an external trig- ger can be defined. the tioa or tiob external trigger selection bit in cmrn (cmrn.abetrg) selects tioa or tiob input signal as an external trigger. the external trigger edge selection bit in cmrn (cmrn.etredg) defines the edge (rising, falling or both) detected to generate an external trig- ger. if cmrn.etrgedg is zero (none), the external trigger is disabled.
837 32117b?avr-03/11 at32uc3c figure 31-4. capture mode timer_clock1 xc 0 xc 1 xc 2 tcclks clki qs r s r q clksta clken clkdis burst tiob capture register a compare rc = 16-bit counter abetrg swtrg etrgedg cpctrg imr trig ldrbs ldras etrgs sr lovrs covfs sync 1 mtiob tioa mtioa ldra ldbstop if ra is not loaded or rb is loaded if ra is loaded ldbdis cpcs int ed g e det ect or ldrb clk ovf reset timer/counter channel edge detector edge detector capture register b register c timer_clock2 timer_clock3 timer_clock4 timer_clock5
838 32117b?avr-03/11 at32uc3c 31.6.3 waveform operating mode waveform operating mode is entered by writing a one to the cmrn.wave bit. in waveform operating mode the tc channel generates one or two pwm signals with the same frequency and independently programmable duty cy cles, or generates different types of one- shot or repetitive pulses. in this mode, tioa is configured as an output and tiob is defined as an output if it is not used as an external event. figure 31-5 on page 839 shows the configuration of the tc channel when programmed in waveform operating mode. 31.6.3.1 waveform selection depending on the waveform se lection field in cmrn (cmrn. wavsel), the behavior of cvn varies. with any selection, ra, rb and rc can all be used as compare registers. ra compare is used to control the tioa output, rb compare is used to control the tiob output (if correctly configured) and rc compare is used to control tioa and/or tiob outputs.
839 32117b?avr-03/11 at32uc3c figure 31-5. waveform mode tcclks clki qs r s r q clksta clken clkdis cpcdis burst tiob register a compare rc = cpcstop 16-bit counter eevt eev t e d g sync swtrg en etr g wavsel imr tr i g acpc acpa aeevt aswtrg bcpc bcpb beevt bswtrg tioa mtioa tiob mtiob cpas covfs etrgs sr cpcs cpbs clk ovf reset output contr oller o utput cont r oller int 1 ed g e det ect o r timer/counter channel timer_clock1 xc 0 xc 1 xc 2 wavsel register b register c compare rb = compare ra = timer_clock2 timer_clock3 timer_clock4 timer_clock5
840 32117b?avr-03/11 at32uc3c 31.6.3.2 wavsel = 0 when cmrn.wavsel is zero, the value of cv n is incremented fr om 0 to 0xffff. once 0xffff has been reached, the value of cvn is re set. incrementation of cvn starts again and the cycle continues. see figure 31-6 on page 840 . an external event trigger or a software trigger can reset the value of cvn. it is important to note that the trigger may occur at any time. see figure 31-7 on page 841 . rc compare cannot be programmed to generate a trigger in this configuration. at the same time, rc compare can stop the counter clock (cmrn.cpcstop = 1) and/or disable the counter clock (cmrn.cpcdis = 1). figure 31-6. wavsel= 0 without trigger time counter value rc rb ra tiob tioa counter cleared by compare match with 0xffff 0xffff waveform examples
841 32117b?avr-03/11 at32uc3c figure 31-7. wavsel= 0 with trigger 31.6.3.3 wavsel = 2 when cmrn.wavsel is two, the value of cvn is incremented from zero to the value of rc, then automatically reset on a rc compare. once the value of cvn has been reset, it is then incremented and so on. see figure 31-8 on page 842 . it is important to note that cvn can be reset at any time by an external event or a software trig- ger if both are programmed correctly. see figure 31-9 on page 842 . in addition, rc compare can stop the counter clock (cmrn.cpcstop) and/or disable the counter clock (cmrn.cpcdis = 1). time counter value rc rb ra tiob tioa counter cleared by compare match with 0xffff 0xffff waveform examples counter cleared by trigger
842 32117b?avr-03/11 at32uc3c figure 31-8. wavsel = 2 without trigger figure 31-9. wavsel = 2 with trigger 31.6.3.4 wavsel = 1 when cmrn.wavsel is one, the value of cvn is incremented from 0 to 0xffff. once 0xffff is reached, the value of cvn is decremented to 0, then re-incremented to 0xffff and so on. see figure 31-10 on page 843 . time counter value rc rb ra tiob tioa counter cleared by compare match with rc 0xffff waveform examples time counter value r c r b r a tiob tioa counter cleared by compare match with rc 0xffff waveform examples counter cleared by trigger
843 32117b?avr-03/11 at32uc3c a trigger such as an external event or a software trigger can modify cvn at any time. if a trigger occurs while cvn is incrementing, cvn then decrements. if a trigger is received while cvn is decrementing, cvn then increments. see figure 31-11 on page 843 . rc compare cannot be programmed to generate a trigger in this configuration. at the same time, rc compare can stop the counter clock (cmrn.cpcstop = 1) and/or dis- able the counter clock (cmrn.cpcdis = 1). figure 31-10. wavsel = 1 without trigger figure 31-11. wavsel = 1 with trigger time counter value rc rb ra tiob tioa counter decremented by compare match with 0xffff 0xffff waveform examples time counter value tiob tioa counter decremented by compare matc h with 0xffff 0xffff waveform examples counter decremented by trigger rc rb ra counter incremented by trigger
844 32117b?avr-03/11 at32uc3c 31.6.3.5 wavsel = 3 when cmrn.wavsel is three, the value of cvn is incremented from ze ro to rc. once rc is reached, the value of cvn is decremented to zero, then re-incremented to rc and so on. see figure 31-12 on page 844 . a trigger such as an external event or a software trigger can modify cvn at any time. if a trigger occurs while cvn is incrementing, cvn then decrements. if a trigger is received while cvn is decrementing, cvn then increments. see figure 31-13 on page 845 . rc compare can stop the counter clock (cmrn.cp cstop = 1) and/or disable the counter clock (cmrn.cpcdis = 1). figure 31-12. wavsel = 3 without trigger time counter value rc rb ra tiob tioa counter cleared by compare match with rc 0xffff waveform examples
845 32117b?avr-03/11 at32uc3c figure 31-13. wavsel = 3 with trigger 31.6.3.6 external event/trigger conditions an external event can be programmed to be detected on one of the clock sources (xc0, xc1, xc2) or tiob. the external event selected can then be used as a trigger. the external event selection field in cmrn (cmrn.eevt) selects the external trigger. the external event edge selection field in cmrn (cmrn.eevtedg) defines the trigger edge for each of the possible external triggers (rising, fa lling or both). if cmrn.eevtedg is written to zero, no external event is defined. if tiob is defined as an ex ternal event signal (cmrn.eevt = 0), tiob is no longer used as an output and the compare register b is not used to generate waveforms and subsequently no irqs. in this case the tc channel can only generate a waveform on tioa. when an external event is defined, it can be used as a trigger by writing a one to the cmrn.enetrg bit. as in capture mode, the sync signal and the softw are trigger are also available as triggers. rc compare can also be used as a trigger depending on the cmrn.wavsel field. 31.6.3.7 output controller the output controller defines the output level changes on tioa and tiob following an event. tiob control is used only if tiob is defin ed as output (not as an external event). the following events control tioa and tiob: ? software trigger ? external event ? rc compare ra compare controls tioa and rb compare controls tiob. each of these events can be pro- grammed to set, clear or toggle the output as defined in the following fields in cmrn: ? rc compare effect on tiob (cmrn.bcpc) time counter value tiob tioa counter decremented by compare match with rc 0xffff waveform examples rc rb ra counter decremented by trigger counter incremented by trigger
846 32117b?avr-03/11 at32uc3c ? rb compare effect on tiob (cmrn.bcpb) ? rc compare effect on tioa (cmrn.acpc) ? ra compare effect on tioa (cmrn.acpa)
847 32117b?avr-03/11 at32uc3c 31.7 user interface table 31-3. tc register memory map offset register register name access reset 0x00 channel 0 control register ccr0 write-only 0x00000000 0x04 channel 0 mode register cmr0 read/write 0x00000000 0x10 channel 0 counter value cv0 read-only 0x00000000 0x14 channel 0 register a ra0 read/write (1) 0x00000000 0x18 channel 0 register b rb0 read/write (1) 0x00000000 0x1c channel 0 register c rc0 read/write 0x00000000 0x20 channel 0 status register sr0 read-only 0x00000000 0x24 interrupt enable register ier0 write-only 0x00000000 0x28 channel 0 interrupt disable register idr0 write-only 0x00000000 0x2c channel 0 interrupt mask register imr0 read-only 0x00000000 0x40 channel 1 control register ccr1 write-only 0x00000000 0x44 channel 1 mode register cmr1 read/write 0x00000000 0x50 channel 1 counter value cv1 read-only 0x00000000 0x54 channel 1 register a ra1 read/write (1) 0x00000000 0x58 channel 1 register b rb1 read/write (1) 0x00000000 0x5c channel 1 register c rc1 read/write 0x00000000 0x60 channel 1 status register sr1 read-only 0x00000000 0x64 channel 1 interrupt enable register ier1 write-only 0x00000000 0x68 channel 1 interrupt disable register idr1 write-only 0x00000000 0x6c channel 1 interrupt mask register imr1 read-only 0x00000000 0x80 channel 2 control register ccr2 write-only 0x00000000 0x84 channel 2 mode register cmr2 read/write 0x00000000 0x90 channel 2 counter value cv2 read-only 0x00000000 0x94 channel 2 register a ra2 read/write (1) 0x00000000 0x98 channel 2 register b rb2 read/write (1) 0x00000000 0x9c channel 2 register c rc2 read/write 0x00000000 0xa0 channel 2 status register sr2 read-only 0x00000000 0xa4 channel 2 interrupt enable register ier2 write-only 0x00000000 0xa8 channel 2 interrupt disable register idr2 write-only 0x00000000 0xac channel 2 interrupt mask register imr2 read-only 0x00000000 0xc0 block control register bcr write-only 0x00000000 0xc4 block mode register bmr read/write 0x00000000 0xf8 features register features read-only - (2) 0xfc version register version read-only - (2)
848 32117b?avr-03/11 at32uc3c notes: 1. read-only if cmrn.wave is zero. 2. the reset values are device specific. please re fer to the module config uration section at the end of this chapter.
849 32117b?avr-03/11 at32uc3c 31.7.1 channel control register name: ccr access type: write-only offset: 0x00 + n * 0x40 reset value: 0x00000000 ? swtrg: software trigger command 1: writing a one to this bit will perform a software tr igger: the counter is reset and the clock is started. 0: writing a zero to this bit has no effect. ? clkdis: counter cl ock disable command 1: writing a one to this bit will disable the clock. 0: writing a zero to this bit has no effect. ? clken: counter clock enable command 1: writing a one to this bit will enab le the clock if clkdis is not one. 0: writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - swtrg clkdis clken
850 32117b?avr-03/11 at32uc3c 31.7.2 channel mode register: capture mode name: cmr access type: read/write offset: 0x04 + n * 0x40 reset value: 0x00000000 ? ldrb: rb loading selection ? ldra: ra loading selection ?wave 1: capture mode is disabled (waveform mode is enabled). 0: capture mode is enabled. ? cpctrg: rc compare trigger enable 1: rc compare resets the counter and starts the counter clock. 0: rc compare has no effect on the counter and its clock. ? abetrg: tioa or tiob external trigger selection 1: tioa is used as an external trigger. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - ldrb ldra 15 14 13 12 11 10 9 8 wave cpctrg - - - abetrg etrgedg 76543210 ldbdis ldbstop burst clki tcclks ldrb edge 0 none 1 rising edge of tioa 2 falling edge of tioa 3 each edge of tioa ldra edge 0 none 1 rising edge of tioa 2 falling edge of tioa 3 each edge of tioa
851 32117b?avr-03/11 at32uc3c 0: tiob is used as an external trigger. ? etrgedg: external trigger edge selection ? ldbdis: counter clock disable with rb loading 1: counter clock is disabled when rb loading occurs. 0: counter clock is not disabled when rb loading occurs. ? ldbstop: counter clock stopped with rb loading 1: counter clock is stopped when rb loading occurs. 0: counter clock is not stopped when rb loading occurs. ? burst: burst signal selection ? clki: clock invert 1: the counter is incremented on falling edge of the clock. 0: the counter is incremented on rising edge of the clock. ? tcclks: clock selection etrgedg edge 0 none 1 rising edge 2 falling edge 3 each edge burst burst signal selection 0 the clock is not gated by an external signal 1 xc0 is anded with the selected clock 2 xc1 is anded with the selected clock 3 xc2 is anded with the selected clock tcclks clock selected 0timer_clock1 1timer_clock2 2timer_clock3 3timer_clock4 4timer_clock5 5xc0 6xc1 7xc2
852 32117b?avr-03/11 at32uc3c 31.7.3 channel mode register: waveform mode name: cmr access type: read/write offset: 0x04 + n * 0x40 reset value: 0x00000000 ? bswtrg: software trigger effect on tiob ? beevt: external event effect on tiob 31 30 29 28 27 26 25 24 bswtrg beevt bcpc bcpb 23 22 21 20 19 18 17 16 aswtrg aeevt acpc acpa 15 14 13 12 11 10 9 8 wave wavsel enetrg eevt eevtedg 76543210 cpcdis cpcstop burst clki tcclks bswtrg effect 0 none 1set 2clear 3 toggle beevt effect 0 none 1set 2clear 3 toggle
853 32117b?avr-03/11 at32uc3c ? bcpc: rc compare effect on tiob ? bcpb: rb compare effect on tiob ? aswtrg: software trigger effect on tioa ? aeevt: external event effect on tioa ? acpc: rc compare effect on tioa bcpc effect 0 none 1set 2clear 3 toggle bcpb effect 0 none 1set 2clear 3 toggle aswtrg effect 0 none 1set 2clear 3 toggle aeevt effect 0 none 1set 2clear 3 toggle acpc effect 0 none 1set 2clear 3 toggle
854 32117b?avr-03/11 at32uc3c ? acpa: ra compare effect on tioa ?wave 1: waveform mode is enabled. 0: waveform mode is disabled (capture mode is enabled). ? wavsel: waveform selection ? enetrg: external event trigger enable 1: the external event resets the counter and starts the counter clock. 0: the external event has no effect on the counter and its clock. in this case, the selected external event only controls the t ioa output. ? eevt: external event selection note: 1. if tiob is chosen as the external event signal, it is conf igured as an input and no longer generates waveforms and subse- quently no irqs . ? eevtedg: external ev ent edge selection ? cpcdis: counter clock disable with rc compare 1: counter clock is disabled when counter reaches rc. 0: counter clock is not disabled when counter reaches rc. acpa effect 0 none 1set 2clear 3 toggle wavsel effect 0 up mode without automatic trigger on rc compare 1 updown mode without automat ic trigger on rc compare 2 up mode with automatic trigger on rc compare 3 updown mode with automatic trigger on rc compare eevt signal selected as exte rnal event tiob direction 0 tiob input (1) 1 xc0 output 2 xc1 output 3 xc2 output eevtedg edge 0none 1 rising edge 2 falling edge 3 each edge
855 32117b?avr-03/11 at32uc3c ? cpcstop: counter clock stopped with rc compare 1: counter clock is stopped when counter reaches rc. 0: counter clock is not stopped when counter reaches rc. ? burst: burst signal selection ? clki: clock invert 1: counter is incremented on falling edge of the clock. 0: counter is incremented on rising edge of the clock. ? tcclks: clock selection burst burst signal selection 0 the clock is not gated by an external signal. 1 xc0 is anded with the selected clock. 2 xc1 is anded with the selected clock. 3 xc2 is anded with the selected clock. tcclks clock selected 0timer_clock1 1timer_clock2 2timer_clock3 3timer_clock4 4timer_clock5 5xc0 6xc1 7xc2
856 32117b?avr-03/11 at32uc3c 31.7.4 channel counter value register name: cv access type: read-only offset: 0x10 + n * 0x40 reset value: 0x00000000 ?cv: counter value cv contains the counter value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 cv[15:8] 76543210 cv[7:0]
857 32117b?avr-03/11 at32uc3c 31.7.5 channel register a name: ra access type: read-only if cmrn.wave = 0, read/write if cmrn.wave = 1 offset: 0x14 + n * 0x40 reset value: 0x00000000 ? ra: register a ra contains the register a value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ra[15:8] 76543210 ra[7:0]
858 32117b?avr-03/11 at32uc3c 31.7.6 channel register b name: rb access type: read-only if cmrn.wave = 0, read/write if cmrn.wave = 1 offset: 0x18 + n * 0x40 reset value: 0x00000000 ? rb: register b rb contains the register b value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 rb[15:8] 76543210 rb[7:0]
859 32117b?avr-03/11 at32uc3c 31.7.7 channel register c name: rc access type: read/write offset: 0x1c + n * 0x40 reset value: 0x00000000 ? rc: register c rc contains the register c value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 rc[15:8] 76543210 rc[7:0]
860 32117b?avr-03/11 at32uc3c 31.7.8 channel status register name: sr access type: read-only offset: 0x20 + n * 0x40 reset value: 0x00000000 note: reading the status register will also clear th e interrupt bit for the co rresponding interrupts. ? mtiob: tiob mirror 1: tiob is high. if cmrn.wave is zero, this means that tiob pi n is high. if cmrn.wave is one, this means that tiob is driven high. 0: tiob is low. if cmrn.wave is zero, this means that tiob pi n is low. if cmrn.wave is one, this means that tiob is driven low. ? mtioa: tioa mirror 1: tioa is high. if cmrn.wave is zero, this means that tioa pin is high. if cmrn.wave is one, th is means that tioa is driven high. 0: tioa is low. if cmrn.wave is zero, this means that tioa pin is low. if cmrn.wave is one, this means that tioa is driven low. ? clksta: clock enabling status 1: this bit is set when the clock is enabled. 0: this bit is cleared when the clock is disabled. ? etrgs: external trigger status 1: this bit is set when an external trigger has occurred. 0: this bit is cleared when the sr register is read. ? ldrbs: rb loading status 1: this bit is set when an rb load has occurred and cmrn.wave is zero. 0: this bit is cleared when the sr register is read. ? ldras: ra loading status 1: this bit is set when an ra load has occurred and cmrn.wave is zero. 0: this bit is cleared when the sr register is read. ? cpcs: rc compare status 1: this bit is set when an rc compare has occurred. 0: this bit is cleared when the sr register is read. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - - mtiob mtioa clksta 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
861 32117b?avr-03/11 at32uc3c ? cpbs: rb compare status 1: this bit is set when an rb compare has occurred and cmrn.wave is one. 0: this bit is cleared when the sr register is read. ? cpas: ra compare status 1: this bit is set when an ra compare has occurred and cmrn.wave is one. 0: this bit is cleared when the sr register is read. ? lovrs: load overrun status 1: this bit is set when ra or rb have been loaded at l east twice without any read of the corresponding register and cmrn.wave is zero. 0: this bit is cleared when the sr register is read. ? covfs: counter overflow status 1: this bit is set when a counter overflow has occurred. 0: this bit is cleared when the sr register is read.
862 32117b?avr-03/11 at32uc3c 31.7.9 channel interrupt enable register name: ier access type: write-only offset: 0x24 + n * 0x40 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
863 32117b?avr-03/11 at32uc3c 31.7.10 channel interrupt disable register name: idr access type: write-only offset: 0x28 + n * 0x40 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
864 32117b?avr-03/11 at32uc3c 31.7.11 channel interrupt mask register name: imr access type: read-only offset: 0x2c + n * 0x40 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
865 32117b?avr-03/11 at32uc3c 31.7.12 block control register name: bcr access type: write-only offset: 0xc0 reset value: 0x00000000 ? sync: synchro command 1: writing a one to this bit asserts the sync signal which generates a software trigger simultaneously for each of the channels . 0: writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------sync
866 32117b?avr-03/11 at32uc3c 31.7.13 block mode register name: bmr access type: read/write offset: 0xc4 reset value: 0x00000000 ? tc2xc2s: external clock signal 2 selection ? tc1xc1s: external clock signal 1 selection 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - tc2xc2s tc1xc1s tc0xc0s tc2xc2s signal connected to xc2 0tclk2 1none 2tioa0 3tioa1 tc1xc1s signal connected to xc1 0tclk1 1none 2tioa0 3tioa2
867 32117b?avr-03/11 at32uc3c ? tc0xc0s: external cloc k signal 0 selection tc0xc0s signal connected to xc0 0tclk0 1none 2tioa1 3tioa2
868 32117b?avr-03/11 at32uc3c 31.7.14 features register name: features access type: read-only offset: 0xf8 reset value: - ? brpbhsb: bridge type is pb to hsb 1: bridge type is pb to hsb. 0: bridge type is not pb to hsb. ? updnimpl: up/down is implemented 1: up/down counter capability is implemented. 0: up/down counter capability is not implemented. ? ctrsize: counter size this field indicates the size of the counter in bits. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------- 15 14 13 12 11 10 9 8 - - - - - - brpbhsb updnimpl 76543210 ctrsize
869 32117b?avr-03/11 at32uc3c 31.7.15 version register name: version access type: read-only offset: 0xfc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
870 32117b?avr-03/11 at32uc3c 31.8 module configuration the specific configuration for eac h tc instance is listed in the following tables. the module bus clocks listed here are connected to the system bus clocks according to the table in the power manager section. 31.8.1 clock connections each timer/counter channel can independently select an internal or external clock source for its counter: table 31-4. module clock name module name clock name description tc0 clk_tc0 peripheral bus clock from the pbc clock domain tc1 clk_tc1 peripheral bus clock from the pba clock domain table 31-5. timer/counter clock connections module source name connection tc0 internal timer_clock1 32 khz oscillator clock (osc32k) timer_clock2 pbc clock / 2 (timer0_clock2) timer_clock3 pbc clock / 8 (timer0_clock3) timer_clock4 pbc clock / 32 (timer0_clock4) timer_clock5 pbc clock / 128 (timer0_clock5) external tc0 - clk0 see peripheral multiplexing on i/o line chapter tc0 - clk1 tc0 - clk2 tc1 internal timer_clock1 32 khz oscillator clock (osc32k) timer_clock2 pba clock / 2 (timer1_clock2) timer_clock3 pba clock / 8 (timer1_clock3) timer_clock4 pba clock / 32 (timer1_clock4) timer_clock5 pba clock / 128 (timer1_clock5) external tc1 - clk0 see peripheral multiplexing on i/o line chapter tc1 - clk1 tc1 - clk2
871 32117b?avr-03/11 at32uc3c 32. usb interface (usbc) rev: 2.1.0.14 32.1 features ? compatible with the usb 2.0 specification ? supports full (12m bit/s) and low (1.5mbit/s) speed communication ? supports embedded host ? 7 physical pipes/endpoints in ping-pong mode ? flexible pipe/endpoint configuration and reallocation of data buffers in embedded ram ? supports an infinite number of virtual pipes (alternate pipe) ? up to two memory banks per pipe/endpoint ? built-in dma with multi-packet support through ping-pong mode ? on-chip transceivers with built-in pull-ups and pull-downs ? on-chip embedded host pad wit h a vbus analog comparator 32.2 overview the universal serial bus interface (usbc) modu le complies with the universal serial bus (usb) 2.0 specification, . each pipe/endpoint can be configured into one of several transfer types. it can be associated with one or more memory banks (located inside the embedded system or cpu ram) used to store the current data payload. if two banks are used (?ping-pong? mode), then one bank is read or written by the cpu (or any other hsb master) while the other is read or written by the usbc core. table 32-1 describes the hardware configuration of the usbc module. 32.3 block diagram the usbc interfaces a usb link with a data flow stored in the embedded ram (cpu or hsb). the usbc requires a 48mhz 0.25% reference cl ock, which is the usb generic clock. for more details see ?clocks? on page 874 . the 48mhz clock is used to generate either a 12mhz full-speed or a 1.5mhz low-speed bit clock from the received usb differential data, and to trans- mit data according to full- or low-speed usb devic e tolerances. clock recovery is achieved by a digital phase-locked loop (a dpll, not represented) in the usbc module, which complies with the usb jitter specifications. table 32-1. description of usb pipes/endpoints pipe/endpoint mnemonic max. size number of available banks type 0 pep0 1023 bytes 1 control/is ochronous/bulk/interrupt 1 pep1 1023 bytes 2 control/is ochronous/bulk/interrupt 2 pep2 1023 bytes 2 control/is ochronous/bulk/interrupt ... ... ... ... ... 6 pep6 1023 bytes 2 control/is ochronous/bulk/interrupt
872 32117b?avr-03/11 at32uc3c the usbc module consists of: ? hsb master interface ?user interface ? usb core ? transceiver pads figure 32-1. usbc block diagram note: the usb_vbus pin is 5v tolerant interrupt controller usb interrupts dm usb_vbof usb i/o controller dp user interface scif gclk_usbc @ 48 mhz pb usb 2.0 co r e usb clock domain system clock domain hsb hsb master usb_id usb_vbus (1
873 32117b?avr-03/11 at32uc3c 32.4 i/o lines description table 32-2. i/o lines description pin name pin description type active level usb_vbof usb vbus on/o ff: bus power control port output usbcon.vbuspo usb_vbus vbus: bus power measurement port input dm data -: differential data line - port input/output dp data +: differential data line + port input/output usb_id usb identification: mini connector identification port input low: mini-a plug high z: mini-b plug
874 32117b?avr-03/11 at32uc3c 32.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 32.5.1 i/o lines the usbc pins may be multiplexed with the i/o controller lines. the user must first configure the i/o controller to assign the desired usbc pins to their peripheral functions. if the usb_id pin is used the user must also enable its internal pull-up resistor. 32.5.2 power management if the cpu enters a sleep mode that disables clocks used by the usbc, the usbc will stop func- tioning and resume operation after the system wakes up from sleep mode. 32.5.3 clocks the usbc has two bus clocks connected: on e high speed bus clock (clk_usbc_hsb) and one peripheral bus clock (clk_usbc_pb). thes e clocks are generated by the power man- ager. both clocks are enabled at reset, and can be disabled by the power manager. it is recommended to disable the usbc before disabling the clocks, to avoid freezing the usbc in an undefined state. the 48mhz usb clock is generated by a dedicated generic clock from the scif module. before using the usb, the user must ensure that th e usb generic clock (gclk_usbc) is enabled at 48mhz in the scif module. 32.5.4 interrupts the usbc interrupt request line is connected to the interrupt controller. using the usbc inter- rupt requires the interrupt controller to be programmed first. the usbc asynchronous interrupts can wake the cpu from any sleep mode: ? the id transition interrupt (idti) ? the vbus transition interrupt (vbusti) if the bandgap voltage reference is on (refer to the power manager chapter) ? the wakeup interrupt (wakeup) ? the host wakeup interrupt (hwupi)
875 32117b?avr-03/11 at32uc3c 32.6 functional description 32.6.1 usb general operation 32.6.1.1 initialization after a hardware reset, the usbc is disabled. when enabled, the usbc runs in either device mode or in host mode according to the id detection. if the usb_id pin is not connected to ground an d the pull-up is enabled, the usb_id state bit in the general status re gister (usbsta.id) will be set an d the device mo de will be enabled. if a low level is detected on the usb_id pin, the usbsta.id bit will be cleared and the host mode will be enabled. figure 32-2. general states after a hardware reset, the usbc is in the reset state. in this state: ? the module is disabled. the usbc enable bit in the general control register (usbcon.usbe) is reset. ? the module clock is stopped in order to minimize power consumption. the freeze usb clock bit in usbcon (usbcon.frzclk) is set. ? the usb pad is in suspend mode. ? the internal states and registers of the device and host modes are reset. ? the usbsta.id bit and the vbus level bit (u sbsta.vbus) reflect the states of the usb_id and usb_vbus input pins. ? the vbus level bit (usbsta.vbus) reflects the states of the usb_vbus input pins. ? the otg pad enable (otgpade), vbus pola rity (vbuspo), freeze usb clock (frzclk), usbc enable (usbe), usb_id pin enable (u ide), usbc mode (uimod) in usbcon, and the low-speed mode bit in the device general control register (udcon.ls) can be written to by software, so that the user can configure pads and speed before enabling the module. these values are only taken into account once the module has been enabled and unfrozen. after writing a one to usbcon.usbe, the usbc enters device or host mode (according to the id detection) in idle state. refer to section 32.6.2 for the basic operation of the device mode. refer to section 32.6.3 for the basic operation of the host mode. device reset usbe = 0 usbe = 1 id = 1 macro off: usbe = 0 clock stopped: frzclk = 1 usbe = 0 host usbe = 0 hw reset usbe = 1 id = 0
876 32117b?avr-03/11 at32uc3c the usbc can be disabled at any time by writin g a zero to usbcon.usbe, this acts as a hard- ware reset, except that the otgpade, vbuspo, frzclk, uide, and uimod bits in usbcon, and the ls bits in udcon are not reset. 32.6.1.2 interrupts one interrupt vector is assigned to the usbc. see section 32.6.2.18 and section 32.6.3.16 for further details about device and host interrupts. there are two kinds of general interrupts: processing, i.e. their generation is part of the normal processing, and exception, i.e. errors (not related to cpu exceptions). the processing general interrupts are: ? the id transition interrupt (idti) ? the vbus transition interrupt (vbusti) ? the srp interrupt (srpi) ? the role exchange interrupt (roleexi) the exception general interrupts are: ? the vbus error interrupt (vberri) ? the b-connection error interrupt (bcerri) ? the hnp error interrupt (hnperri) ? the suspend time-out interrupt (stoi) see section 32.5.4 for asynchronous interrupts. 32.6.1.3 frozen clock when the usb clock is frozen, it is still possible to access the following bits: otgpade, vbuspo, uide, uimod, frzclk, and usbe in the usbcon register, and ls in the udcon register. when frzclk is set, only the asynchronous interrupts can trigger a usb interrupt (see section 32.5.4 ). 32.6.1.4 speed control ? device mode when the usbc interface is in device mode, the speed selection is done by the udcon.ls bit, connecting an internal pull-up resistor to either dp (full-speed mode) or dm (low-speed mode). the ls bit shall be written before attaching the device, which can be simulated by clearing the udcon.detach bit.
877 32117b?avr-03/11 at32uc3c figure 32-3. speed selection in device mode ? host mode when the usbc interface is in host mode, internal pull-downs are enabled on both dp and dm. the interface detects the speed of the connected device and reflects this in the speed status field (usbsta.speed). 32.6.1.5 data management endpoints and pipe buffers can be allocated anywhere in the embedded memory (cpu ram or hsb ram). see ?ram management? on page 883 . 32.6.1.6 pad suspend figure 32-4 illustrates the behavior of the usb pad in device mode. figure 32-4. pad behavior ? in idle state, the pad is in low power consumption mode. ? in active state, the pad is working. figure 32-5 illustrates the pad events le ading to a pad state change. r pu udcon.detach dp dm udcon.ls vbus idle active usbe = 1 & detach = 0 & suspend usbe = 0 | detach = 1 | suspend
878 32117b?avr-03/11 at32uc3c figure 32-5. pad events the suspend interrupt bit in the device global interrupt register (udint.susp) is set and the wakeup interrupt (udint.wakeup) bit is cleared when a usb suspend state has been detected on the usb bus. this event automatically puts the usb pad in the idle state. the detection of a non-i dle event sets wakeup, clears susp, and wakes the usb pad. the pad goes to the idle state if the module is disabled or if udcon.detach is written to one. it returns to the active state when usbcon.usbe is written to one and detach is written to zero. 32.6.1.7 customizing of embedded host timers it is possible to refine some timers thanks to the timer page (timpage) and timer value (tim- value) fields in usbcon, as shown in table 32-3 . timpage is used to select the timer to be ac cessed while timvalue indicates the time-out value of the selected timer. timpage and timvalue can be read and written. before writing them, the user shall unlock write accesses by writing a one to the time r access unlock (unlock) bit in usbcon. 32.6.1.8 plug-in detection the usb connection is detected by the usb_vbus pad. figure 32-6 shows the architecture of the plug-in detector. susp suspend detected cleared on wakeup wakeup detected cleared by software to acknowledge the interrupt wakeup pad state active idle active table 32-3. customizing of host timers timpage 0b00 awaitvrise time-out 0b01 vbbuspulsing time-out 0b10 pdtmoutcnt time-out 0b11 srpdettmout time-out timvalue 00 20 ms 15 ms 93 ms 10 s 01 50 ms 23 ms 105 ms 100 s 10 70 ms 31 ms 118 ms 1 ms 11 100 ms 40 ms 131 ms 11 ms
879 32117b?avr-03/11 at32uc3c figure 32-6. plug-in detection input block diagram the control logic of the usb_vbus pad outputs two signals: ? the session_valid signal is high when the voltage on the usb_vbus pad is higher than or equal to 1.4v. ? the va_vbus_valid signal is high when the voltage on the usb_vbus pad is higher than or equal to 4.4v. in device mode, the usbsta.vbus bit follows the session_valid comparator output: ? it is set when the voltage on the usb_vbus pad is higher than or equal to 1.4v. ? it is cleared when the voltage on the vbus pad is lower than 1.4v. in host mode, the usbsta.vbus bit follo ws a hysteresis based on session_valid and va_vbus_valid: ? it is set when the voltage on the usb_vbus pad is higher than or equal to 4.4v. ? it is cleared when the voltage on the usb_vbus pad is lower than 1.4v. the vbus transition interrupt (vbusti) bit in usbsta is set on each transition of the usb- sta.vbus bit. the usbsta.vbus bit is operatio nal regardless of whether th e usbc is enabled or not. 32.6.1.9 id detection figure 32-7 shows how the id transitions are detected. figure 32-7. id detection input block diagram vbusti usb_vbus vbus usbsta gnd vdd pad logic logic session_valid va_vbus_valid r pu r pd vbus_pulsing vbus_discharge r pu uimod usbcon usb_id id usbsta vdd uide usbcon 1 0 idti usbsta i/o controller
880 32117b?avr-03/11 at32uc3c the usbc mode (device or host) can be detected by the usb_id pin or selected by writing to usbcon.uimod. this allows the usb_id pin to be used as a general purpose i/o pin even when the usbc interface is enabled. the id transition interrupt (idti) bit in usbsta is set on each transition of the id bit, i.e. when a mini-a plug (host mode) is connected or disconne cted. this does not occur when a mini-b plug in device mode is connected or disconnected. the usbsta.id bit is operational regardless of whether the usbc is enabled or not.
881 32117b?avr-03/11 at32uc3c 32.6.2 usbc device mode operation 32.6.2.1 device enabling in device mode, the usbc supports full- and low-speed data transfers. including the default control endpoint, a total of seven endpoints are provided. they can be con- figured as isochronous, bulk or interrupt types, as described in table 32-1 on page 871 after a hardware reset, the usbc device mode is in the reset state (see section 32.6.1.1 ). in this state, the endpoint banks are disabled and neither dp nor dm are pulled up (detach is one). dp or dm will be pulled up according to the sele cted speed as soon as the detach bit is writ- ten to zero and vbus is present. see ?device mode? for further details. when the usbc is enabled (usbe is one) in device mode, it enters the idle state, minimizing power consumption. being in idle state does not require the usb clocks to be activated. the usbc device mode can be disabled or reset at any time by disabling the usbc (by writing a zero to usbe) or by enab ling host mode (id is zero). 32.6.2.2 usb reset the usb bus reset is initiated by a connected host and managed by hardware. when a usb reset state is detected on the usb bus, the following operations are performed by the controller: ? udcon register is reset except for the detach and spdconf bits. ? device frame number register (udfnum), endpoint n configuration register (uecfgn), and endpoint n control register (ueconn) registers are cleared. ? the data toggle sequencing in all the endpoints are cleared. ? at the end of the reset process, the end of reset (eorst) bit in the udint register is set. 32.6.2.3 endpoint activation when an endpoint is disabled (uerst.epenn = 0) the data toggl e sequence, endp oint n status set (uestan), and ueconn regist ers will be reset. the controller ignores all transactions to this endpoint as long as it is inactive. to complete an endpoint activation, the user should fill out the endpoint descriptor: see figure 32-8 on page 884 . 32.6.2.4 data toggle sequence in order to respond to a clear_feature usb request without disabling the endpoint, the user can clear the data toggle sequence by writing a one to the reset data toggle set bit in the endpoint n control set regi ster (ueconnset.rstdts) 32.6.2.5 busy bank enable in order to make an endpoint bank look busy regardless of its actual state, the user can write a one to the busy bank enable bit in the endpoint n control register (ueconnset.busy0/1es). if a busyne bit is set, any transaction to this bank will be rejected with a nak reply. 32.6.2.6 address setup the usb device address is set up according to the usb protocol.
882 32117b?avr-03/11 at32uc3c ? after all kinds of resets, the usb device address is 0. ? the host starts a setup transacti on with a set_address(addr) request. ? the user writes this address to the usb address field (udcon.uadd), and writes a zero to the address enable bit (udcon.adden), re sulting in the address remaining zero. ? the user sends a zero-length in packet from the control endpoint. ? the user enables the stored usb device address by writing a one to adden. once the usb device address is configured, the controller filters the packets to only accept those targeting the address stored in uadd. uadd and adden should not be written to simu ltaneously. they should be written sequentially, uadd field first. if uadd or adden is cleared, the default device address 0 is used. uadd and adden are cleared: ? on a hardware reset. ? when the usbc is disabled (usbe written to zero). ? when a usb reset is detected. 32.6.2.7 suspend and wakeup when an idle usb bus state has been detected for 3 ms, the controller sets the suspend (susp) interrupt bit in udint. in this case , the transceiver is suspended, reducing power consumption. to further reduce power consumption it is recommended to freeze the usb clock by writing a one to the freeze usb clock (frzclk) bit in usbcon when the usb bus is in suspend mode. the mcu can also enter the idle or frozen sleep mode to further lower power consumption. to recover from the suspend mode, the user shall wait for the wakeup (wakeup) interrupt bit, which is set when a non-idle event is detected, and then write a zero to frzclk. as the wakeup interrupt bit in udint is set when a non-idle event is detected, it can occur regardless of whether the controller is in the suspend mode or not. the susp and wakeup interrupts are thus independent of each other except for that one bit is cleared when the other is set. 32.6.2.8 detach the reset value of the detach bit located in the udcon register, is one. it is possible to initiate a device re-enumeration simply by writing a one and then a zero to detach. detach acts on the pull-up connections of the dp and dm pads. see ?device mode? for fur- ther details. 32.6.2.9 remote wakeup the remote wakeup request (also known as upstream resume) is the only request the device may send on its own initiative. this shoul d be preceded by a device_remote_wakeup request from the host. ? first, the usbc must have detected a ?suspend? state on the bus, i.e. the remote wakeup request can only be sent after a susp interrupt has been set.
883 32117b?avr-03/11 at32uc3c ? the user may then write a one to the remote wakeup (rmwkup) bit in udcon to send an upstream resume to the host initiating the wakeup. this will automatically be done by the controller after 5ms of inactivity on the usb bus. ? when the controller sends the upstream resume, the upstream resume (uprsm) interrupt is set and susp is cleared. ? rmwkup is cleared at the end of the transmitting upstream resume. ? in case of a rebroadcast resume initiated by the host, the end of resume (eorsm) interrupt is set when the rebroadcast resume is completed. 32.6.2.10 ram management endpoint data can be physically allocated anywhere in the embedded ram. the usbc control- ler accesses these endpoints directly through the hsb master (built-in dma). the usbc controller reads the usbc descriptors to know where each endpoint is located. the base address of the usbc descriptor (udesc.udesca) needs to be written by the user. the descriptors can also be allocated anywhere in the embedded ram. before using an endpoint, the user should setup the endpoint address for each bank. depending on the direction, the type, and the packet-mode (single or multi-packet), the user should also ini- tialize the endpoint packet size, and the endpoint c ontrol and status fields, so that the usbc controller does not compute random values from the ram. when using an endpoint the user should read t he uestax.currbk field to know which bank is currently being processed.
884 32117b?avr-03/11 at32uc3c figure 32-8. memory organization each descriptor of an endpoint n consists of four words. ? the address of the endpoint an d the bank used (epn_addr_bk0/1). ? the packet size information for the endpoint and bank (epn_pcksize_bk0/1): table 32-4. epn_pcksize_bk0/1 structure ? auto_zlp: auto zero length packet, see ?multi packet mode for in endpoints? on page 889 . ? multi_packet_size: see ?multi packet mode and single packet mode.? on page 886 . ? byte_count: see ?multi packet mode and single packet mode.? on page 886 . 31 30:16 15 14:0 auto_zlp multi_packet_size - byte_count epn bk0 ep0_c tr _sta_bk0 ep0_pcksize_bk0 ep0_addr_bk0 udesca growing memory addresses descriptor ep0 reserved ep0_c tr _sta_bk1 ep0_pcksize_bk1 ep0_ad d r _bk1 reserved bank0 bank1 +0x000 +0x004 +0x008 +0x00c +0x010 +0x014 +0x018 +0x01c ep1_c tr _sta_bk0 ep1_pcksize_bk0 ep1_addr_bk0 descriptor ep1 reserved ep1_c tr _sta_bk1 ep1_pcksize_bk1 ep1_ad d r _bk1 reserved bank0 bank1 +0x020 +0x024 +0x028 +0x02c +0x030 +0x034 +0x038 +0x03c epn_c tr _sta_bk0 epn_pcksize_bk0 epn_addr_bk0 reserved epn_c tr _sta_bk1 epn_pcksize_bk1 epn_ad d r _bk1 reserved bank0 bank1 descriptor epn epn bk1 usb descriptors usb buffers
885 32117b?avr-03/11 at32uc3c ? the control and status fields for the endpoint and bank (epn_ctr_sta_bk0/1): table 32-5. epn_ctr_sta_bk0 /1 structure ? underf: underflow status for isochronous in transfer. see ?data flow error? on page 892 . ? overf: overflow status for isochronous out transfer. see ?data flow error? on page 892 . ? crcerr: crc error status for isochronous out transfer. see ?crc error? on page 892 . ? stallrq_next: stall request for the next transfer. see ?stall request? on page 885 . 32.6.2.11 stall request for each endpoint, the stall management is performed using: ? the stall request (stallrq) bit in ueconn is set to initiate a stall request. ? the stalled interrupt (stalledi) bit in uestan is set when a stall handshake has been sent. to answer requests with a stall handshake, stallrq has to be set by writing a one to the stall request set (stallrqs) bit. all following requests will be discarded (rxouti, etc. will not be set) and handshaked with a stall until the stallrq bit is cleared, by receiving a new setup packet (for control endpoints) or by writing a one to the stall request clear (stall- rqc) bit. each time a stall handshake is sent, the stal ledi bit is set by the usbc and the epnint interrupt is set. the user can use the descriptor to manage stall requests. the usbc controller reads the epn_ctr_sta_bk0/1.stallrq_next bit after succ essful transactions and if it is one the usbc controller will set uecon.stallrq. the st all_next bit will be cleared upon receiving a setup transaction and the usbc cont roller will then clear the stallrq bit. ? special considerations for control endpoints if a setup packet is received at a control endpoint where a stall request is active, the received setup interrupt (rxstpi) bit in ue stan is set, and the stallrq and stalledi bits are cleared. it allows the setup to be always acked as required by the usb standard. this management simplifies the enumeration process management. if a command is not sup- ported or contains an error, the user requests a stall and can return to the main task, waiting for the next setup request. ? stall handshake and retry mechanism the retry mechanism has priority over the stall handshake. a stall handshake is sent if the stallrq bit is set and if there is no retry required. 31:19 18 17 16 15:1 0 status elements control elements - underf overf crcerr - stallrq_next
886 32117b?avr-03/11 at32uc3c 32.6.2.12 multi packet mode and single packet mode. single packet mode is the default mode where one usb packet is managed per bank. the multi-packet mode allows the user to manage data exceeding the maximum endpoint size (uecfgn.epsize) for an endpoint bank across mult iple packets without software intervention. this mode can also be coupled with the ping-pong mode. ? for an out endpoint, the epn_pcksize_bk0/1.multi_packet_size field should be configured correctly to enable the multi-packet mode. see ?multi packet mode for out endpoints? on page 891 . for single packet mode, the multi_packet_size should be initialized to 0. ? for an in endpoint, the epn_pcksize_bk0/1.byte_count field should be configured correctly to enable the multi-packet mode. see ?multi packet mode for in endpoints? on page 889 . for single packet mode, the byt e_count should be less than epsize. 32.6.2.13 management of control endpoints ? overview a setup request is always acked. when a new setup packet is received, the rxstpi is set, but not the received out data interrupt (rxouti) bit. the fifo control (fifocon) bit in ueconn is ir relevant for control endpoints. the user should therefore never use it for these endpoints. when read, this value is always zero. control endpoints are managed using: ? the rxstpi bit: is set when a new setup packet is received. this has to be cleared by firmware in order to acknowledge the packet and to free the bank. ? the rxouti bit: is set when a new out packet is received. this has to be cleared by firmware in order to acknowledge the packet and to free the bank. ? the transmitted in data interrupt (txini) bit: is set when the current bank is ready to accept a new in packet. this has to be cleared by firmware in order to send the packet. ? control write figure 32-9 on page 887 shows a control write transaction. during the status stage, the control- ler will not necessarily send a nak on the first in token: ? if the user knows the exact number of descript or bytes that will be read, the status stage can be predicted, and a zero-length packet can be sent after the next in token. ? alternatively the bytes can be read until the naked in interrupt (nakini) is triggered, notifying that all bytes are sent by the host and that the transaction is now in the status stage.
887 32117b?avr-03/11 at32uc3c figure 32-9. control write ? control read figure 32-10 on page 887 shows a control read transaction. the usbc has to manage the simultaneous write requests from the cpu and usb host. figure 32-10. control read a nak handshake is always generated as the first status stage command. the uestan.nakini bit is set. it allows the user to know that t he host aborts the in data stage. as a consequence, the user should stop processing the in data stage and should prepare to receive the out status stage by checking the uestan.rxouti bit. the out retry is always acked. this out recept ion sets rxouti. handle this with the follow- ing software algorithm: // process the in data stage set txini wait for rxouti (rising) or txini (falling) if rxouti is high, then process the out status stage if txini is low, then return to process the in data stage once the out status stage has been received, the usbc waits for a setup request. the setup request has priority over all other requests and will be acked. setup rxstpi rxouti txini usb bus hw sw out hw sw out hw sw in in nak sw data setup status setup rxstpi rxouti txini usb bus hw sw in hw sw in out out nak sw sw hw wr enable host wr enable cpu data setup status
888 32117b?avr-03/11 at32uc3c 32.6.2.14 management of in endpoints ? overview in packets are sent by the usbc device controller upon in requests from the host. the endpoint and its descriptor in ram must be pre configured (see section ?ram manage- ment? on page 883 for more details). when the current bank is clear , the txini and fifo control (u econn.fifocon) bits will be set simultaneously. this triggers an epnint interrupt if the transmitted in data interrupt enable (txine) bit in ueconn is one. txini shall be cleared by software (by writing a one to the transmitted in data interrupt enable clear bit in the endpoint n control clear regi ster (ueconnclr.txinic)) to acknowledge the interrupt. this has no effect on the endpoint fifo. the user writes the in data to the bank referenced by the epn descriptor and allows the usbc to send the data by writing a one to the fifo control clear (ueconnclr.fifoconc) bit. this will also cause a switch to the next bank if the in endpoint is composed of multiple banks. the txini and fifocon bits will be updated accordingly. txini should always be cleared before clearing fifocon to avoid missing an txini event. figure 32-11. example of an in endpoint with one data bank figure 32-12. example of an in endpoint with two data banks in data (bank 0) ack txini fifocon hw write data to cpu bank 0 sw sw sw sw in nak write data to cpu bank 0 in data (bank 0) ack txini fifocon write data to cpu bank 0 sw sw sw sw in data (bank 1) ack write data to cpu bank 1 sw hw write data to cpu bank0
889 32117b?avr-03/11 at32uc3c ? detailed description the data is written according to this sequence: ? when the bank is empty, txini and fifocon are set, which triggers an epnint interrupt if txine is one. ? the user acknowledges the interrupt by clearing txini. ? the user reads the uestax.currbk fiel d to see which th e current bank is. ? the user writes the data to the current bank, located in ram as described by its descriptor: epn_addr_bk0/1. ? the user should write the size of the in packet into the usb descriptor: epn_pcksize_bk0/1.byte_count. ? the user allows the controller to send the bank contents and switches to the next bank (if any) by clearing fifocon. if the endpoint uses several banks, the current one can be written while the previous one is being read by the host. when the user clears fifo con, the next current bank may already be clear and txini is set immediately. an ?abort? stage can be produced when a zero-length out packet is received during an in stage of a control or isochronou s in transaction. the kill in ba nk (killbk) bit in ueconn is used to kill the last written bank. the best way to man age this abort is to apply the algorithm rep- resented on figure 32-13 on page 889 . see ?endpoint n control register? on page 938 for more details about the killbk bit. figure 32-13. abort algorithm ? multi packet mode for in endpoints in multi packet mode, the user can prepare n usb packets in the bank to be sent on a multiple in transaction. the packet sizes will equal ue cfgn.epsize unless t he auto_zlp option is endpoint abort abort done abort is based on the fact that no bank is busy, i.e., that nothing has to be sent disable the txini interrupt. eprstn = 1 nbusybk == 0? yes txinec = 1 no killbks = 1 killbk == 1? yes kill the last written bank. wait for the end of the procedure no
890 32117b?avr-03/11 at32uc3c set, or if the total byte count is not an integr al multiple of epsize, whereby the last packet should be short. to enable the multi packet mode, the user should configure the endpoint descriptor (epn_pcksize_bk0/1.byte_count) to the tota l size of the multi packet, which should be larger than the end point size (epsize). since the epn_pcksize_bk0/1.multi_packet_size is incremented (by the transmitted packet size) after each successful transaction, it should be set to zero when setting up a new multi packet transfer. the epn_pcksize_bk0/1.multi_packet_size is cleared by hardware when all the bank contents have been sent. the bank is consider ed as ready and the tx_in flag is set when: ? a short packet (smaller than epsize) has been transmitted. ? a packet has been successfully transmitted, the updated multi_packet_size equals the byte_count, and the auto_zlp field is not set. ? an extra zero length packet has been automatically sent for the last transfer of the current bank, if byte_count is a multiple of epsize and auto_zlp is set. 32.6.2.15 management of out endpoints ? overview the endpoint and its descriptor in ram must be pre configured, see section ?ram management? on page 883 for more details. when the current bank is full, the rxouti an d fifo control (ueconn.fifocon) bits will be set simultaneously. this trigge rs an epnint interrupt if the received out data interrupt enable (rxoute) bit in ueconn is one. rxouti shall be cleared by soft ware (by writing a one to the re ceived out data interrupt clear (rxoutic) bit) to acknowledge the interrupt. this has no effect on the endpoint fifo. the user reads the out data from the ram and clears the fifocon bit to free the bank. this will also cause a switch to the next bank if th e out endpoint is compos ed of multiple banks. rxouti should always be cleared before clear ing fifocon to avoid missing an rxouti event. figure 32-14. example of an out endpoint with one data bank out data (bank 0) ack rxouti fifocon hw out data (bank 0) ack hw sw sw sw read data from cpu bank 0 read data from cpu bank 0 nak
891 32117b?avr-03/11 at32uc3c figure 32-15. example of an out endpoint with two data banks ? detailed description before using the out endpoint, one should properly initialize its descriptor for each bank. see figure 32-8 on page 884 . the data is read, according to this sequence: ? when the bank is full, rxouti and fifocon ar e set, which triggers an epnint interrupt if rxoute is one. ? the user acknowledges the interrupt by writing a one to rxoutic in order to clear rxouti. ? the user reads the uestax.currbk fiel d to know the current bank number. ? the user reads the byte count of the current bank from the descriptor in ram (epn_pcksize_bk0/1.byte_count) to know how many bytes to read. ? the user reads the data in the current bank, located in ram as described by its descriptor: epn_addr_bk0/1. ? the user frees the bank and switches to the next bank (if any) by clearing fifocon. if the endpoint uses several banks, the current one can be read while the next is being written by the host. when the user clears fifocon, the following bank may already be ready and rxouti will be immediately set. ? multi packet mode for out endpoints in multi packet mode, the user can extend the si ze of the bank allowing the storage of n usb packets in the bank. to enable the multi packet mode, the user should configure the endpoint descriptor (epn_pcksize_bk0/1.multi_packet_size) to match the size of the multi packet.this value should be a multiple of the endpoint size (uecfgn.epsize). since the epn_pcksize_bk0/1.byte_count is in cremented (by the received packet size) after each successful transaction, it should be set to zero when setting up a new multi packet transfer. as for single packet mode, the number of received data bytes is stored in the byte_cnt field. the bank is considered as ?valid? and the rx_out flag is set when: out data (bank 0) ack rxouti fifocon hw out data (bank 1) ack sw sw read data from cpu bank 0 hw sw read data from cpu bank 1
892 32117b?avr-03/11 at32uc3c ? a packet has been successfully received and the updated byte_count equals the multi_packet_size. ? a short packet (smaller than epsize) has been received. 32.6.2.16 data flow error this error exists only for isochronous in/out endpoints. it sets the errorflow interrupt (errorfi) bit in uestan, which triggers an epnin t interrupt if the errorflow interrupt enable (errorfe) bit is one. the user can chec k the epn_ctr_sta_bk0/1.underf and overf bits in the endpoint descriptor to see which current bank has been affected. ? an underflow can occur during in stage if the host attempts to read from an empty bank. a zero-length packet is then automatically sent by the usbc. the endpoint descriptor epn_ctr_sta_bk0/1.underf points out the bank from which the in data should have originated. if a new successful transaction occurs, the underf bit is overwritten to 0 only if the uestan.errorfi is cleared. ? an overflow can occur during the out stage if the host tries to send a packet while the bank is full. typically this occurs when a cpu is no t fast enough. the packet data is not written to the bank and is lost. the endpoint descriptor epn_ctr_sta_bk0/1.overf points out which bank the out data was destined to. if the uestan.errorfi bit is cleared and a new transaction is su ccessful, the overf bit will be overwritten to zero. 32.6.2.17 crc error this error exists only for isochronous out endpoints. it sets the crc error interrupt (crcerri) bit in uestan, which triggers an epnint interrupt if the crc error interrupt enable (crcerre) bit is one. a crc error can occur during an isochronous out stage if the usbc detects a corrupted received packet. the out packet is stored in the bank as if no crc error had occurred (rxouti is set). the user can also check the endpoint descriptor to see which current bank is impacted by the crc error by reading epn_ctr_sta_bk0/1.crcerr. 32.6.2.18 interrupts there are two kinds of device interrupts: processing, i.e. their generation is part of the normal processing, and exception, i.e. errors not related to cpu exceptions. ? global interrupts the processing device global interrupts are: ? the suspend (susp) interrupt ? the start of frame (sof) interrupt with no frame number crc error (the frame number crc error (fncerr) bit in the device fram e number (udfnum) register is zero) ? the end of reset (eorst) interrupt ? the wakeup (wakeup) interrupt ? the end of resume (eorsm) interrupt ? the upstream resume (uprsm) interrupt ? the endpoint n (epnint) interrupt the exception device global interrupts are:
893 32117b?avr-03/11 at32uc3c ? the start of frame (sof) interrupt with a frame number crc error (fncerr is one) ? endpoint interrupts the processing device endpoint interrupts are: ? the transmitted in data interrupt (txini) ? the received out data interrupt (rxouti) ? the received setup interrupt (rxstpi) ? the number of busy banks (nbusybk) interrupt the exception device endpoint interrupts are: ? the errorflow interrupt (errorfi) ? the naked out interrupt (nakouti) ? the naked in interrupt (nakini) ? the stalled interrupt (stalledi) ? the crc error interrupt (crcerri)
894 32117b?avr-03/11 at32uc3c 32.6.3 usb host operation 32.6.3.1 host enabling figure 32-16 on page 894 describes the usbc host mode main states. figure 32-16. host mode states after a hardware reset, the usbc host mode is in the reset state (see section 32.6.1.1 ). when the usbc is enabled (usbcon.usbe = 1) in host mode (usbsta.id = 0) it enters idle state and waits for a device connection. once a device is connected, the usbc enters the ready state, which does not require the usb clock to be activated. in host mode the usbc will sus pend the usb bus by not transmit ting any start of frame (sof) packets (the start of frame generation enable bit in the host global interrupt register uhcon.sofe is zero). the usbc enters the suspend state when the usb bus is suspended, and exits when sof generation is resumed. 32.6.3.2 device detection a device is detected by the usbc in host mode when dp or dm are not tied low, i.e., when a device dp or dm pull-up resistor is connected. to enable this detection, the host controller has to supply the device with vbus power, wh ich is done when usbsta.vbusrq is one. the device disconnection is detected by the host controller when both dp and dm are pulled down. 32.6.3.3 description of pipes in host mode, the term ?pipe? is used instead of ?endpoint?. a host pipe corresponds to a device endpoint, as illustrated by figure 32-17 on page 895 from the usb specification. ready idle device disconnection device connection macro off clock stopped device disconnection suspend sofe = 1 sofe = 0
895 32117b?avr-03/11 at32uc3c figure 32-17. usb communication flow in host mode, the usbc associates a pipe to a device endpoint, according to the device config- uration descriptors. 32.6.3.4 usb reset the usbc sends a usb reset signal when the user writes a one to the send usb reset bit (uhcon.reset). when the usb reset has been sent, the usb reset sent interrupt bit in the host global interrupt register (uhint.rsti) is set an d all the pipes will be disabled. if the bus was previously in a suspended state (uhcon.sofe is zero) the usbc will switch it to the resume state, causing the bus to asynchronously trigger the host wakeup interrupt (uhint.hwupi). the sofe bit will be set in order to generate sof?s immediately after the usb reset. 32.6.3.5 pipe activation a disabled pipe is inactive, an d will be reset along with its cont ext registers (upconn, upstan, upinrqn, and upcfgn). enabling a pipe is done by writing a one to the pipe n enable bit in the pipe enable/reset register (uprst.penn). when starting an enumeration, the user gets the device descr iptor by sending an get_descriptor usb request. this descripto r contains the maximal packet size of the device default control endpoint (bmaxpacketsize0) which the user should use to reconfigure the size of the default control pipe. 32.6.3.6 address setup once the device has answered the first host requests with the default device address 0, the host assigns a new address to the device. the host co ntroller has to send a usb reset to the device and a set_address(addr) setup request with the new address to be used by the device. once this setup transaction is over, the user writes to the device address field in the ?control and status 1 of endpoint n? word of the host?s pipe n in the usb descriptor (pn_ctr_sta1.pdaddr). all foll owing requests by this pipe will be performed using this new address.
896 32117b?avr-03/11 at32uc3c 32.6.3.7 remote wakeup writing uhcon.sofe to zero when in host mode will cause the usbc to cease sending sof?s on the usb bus and enter the su spend state. the usb device will enter the susp end state 3ms later. the device can awaken the host by sending an upstream resume (remote wakeup feature). when the host detects a non-idle state on the usb bus, it sets the host wakeup interrupt bit (uhint.hwupi). if the non-idle bus state corresponds to an upstream resume (k state), the upstream resume received interrupt bit (uhint.rxrsmi) is set and the user has to generate a downstream resume within 1ms and for at least 20ms. it is required to first enter the ready state by writing a one to uhcon.sofef and then writing a one to the send usb resume bit (uhcon.resume). 32.6.3.8 ram management pipe data can be physically allocated anywhere in the embedded ram. the usbc controller accesses the pipes directly through the hsb master (built-in dma). the usbc controller reads the usbc descriptors to know the location of each pipe. the base address of this usbc descriptor (udesc.udesca) needs to be written by the user. the descriptors can also be allocated anywhere in the embedded ram. before using a pipe, the user should setup the data address for each bank. depending on the direction, pipe type, targeted device address, targeted endpoint number, and packet-mode (sin- gle or multi-packet), the user should also initialize the pipe packet size and the pipe control and status field, so that the usb controller does not compute random values from the ram. when using a pipe, the user should read the upstax.currbk fiel d to know which bank is cur- rently processed.
897 32117b?avr-03/11 at32uc3c figure 32-18. memory organization each pipe n descriptor bank consists of four words. ? the address of the pipe and bank used (pn_addr_bk0/1). ? the packet size information for the pipe and bank (pn_pcksize_bk0/1): table 32-6. pn_pcksize_bk0/1 structure ? auto_zlp: auto zero length packet, see ?multi packet mode for out pipes? on page 902 . ? multi_packet_size: see ?multi packet mode and single packet mode.? on page 886 . ? byte_count: see ?multi packet mode and single packet mode.? on page 886 . 31 30:16 15 14:0 auto_zlp multi_packet_size - byte_count pn bk0 p0_ctr_sta_bk0 p0_pcksize_bk0 p0_addr_bk0 udesca growing memory addresses descriptor p0 p0_ctr_sta1 p0_ctr_sta_bk1 p0_pcksize_bk1 p0_addr_bk1 reserved bank0 bank1 +0x000 +0x004 +0x008 +0x00c +0x010 +0x014 +0x018 +0x01c p1_ctr_sta_bk0 p1_pcksize_bk0 p1_addr_bk0 descriptor p1 p1_ctr_sta1 p1_ctr_sta_bk1 p1_pcksize_bk1 p1_addr_bk1 reserved bank0 bank1 +0x020 +0x024 +0x028 +0x02c +0x030 +0x034 +0x038 +0x03c pn_ctr_sta_bk0 pn_pcksize_bk0 pn_addr_bk0 pn_ctr_sta1 pn_ctr_sta_bk1 pn_pcksize_bk1 pn_addr_bk1 reserved bank0 bank1 descriptor pn pn bk1 usb descriptors usb buffers
898 32117b?avr-03/11 at32uc3c ? the control and status fields for the pipe and bank (pn_ctr_sta_bk0/1): table 32-7. pn_ctr_sta_bk0 /1 structure ? underf: underflow status for isochronous/interrupt in transfers. this status bit is set by hardware at the current bank (where the in packet should have been stored). when a new successful transaction occurs this bit is overwritten to zero if upstax.errorfi has previously been cleared by software. see ?data flow error? on page 902 . ? overf: overflow status for isochronous/interrupt out transfers. this status bit is set by hardware at the current bank (where the out packet should have been loaded). when a new successful transaction occurs this bit is overwritten to zero if upstax.errorfi has previously been cleared by software. see ?data flow error? on page 902 . ? crcerr: crc error status for isochronous in transfers. see ?crc error? on page 902 . ? the control and status 1 of endpoint n (pn_ctr_sta1): table 32-8. pn_ctr_sta1 structure ? persta: pipe error status. see ?persta structure? table. ? permax : should be set by the user. if the pipe error counter (see figure 32-9 on page 898 ) is larger than permax, th e upstax.perri bit is set. ? pepnum : should be set by the user. endpoint number for this pipe. ? pdaddr: should be set by the user. device address for this pipe. table 32-9. persta structure this field can be cleared by software. to avoid read-modify-write issues, the user should: freeze the pipe, wait until the upstax.pfreeze is one, clear the persta field in memory, and then unfreeze the pipe. ? ercnt: pipe error counter. ? crc16er: is set if a crc16 error occurs during an isochronous in transaction. ? touter: is set if a time-out error occurs during a usb transaction. ? pider: is set if a pid error occurs during a usb transaction. ? dapider: is set if a data pid error occurs during a usb transaction. 31:19 18 17 16 15:0 status control - underf overf crcerr - 31:24 23:16 15:12 11:8 7 6:0 status control - persta permax pepnum - pdaddr 23:212019181716 ercnt crc16er touter pider dapider dtgler
899 32117b?avr-03/11 at32uc3c ? dtgler: is set if a data toggle error occurs during a usb transaction. 32.6.3.9 multi packet mode and single packet mode. see ?multi packet mode and single packet mode.? on page 886 and just consider that an out pipe corresponds to an in endpoint, and an in pipe corresponds to an out endpoint. 32.6.3.10 management of control pipes a control transaction is composed of three stages: ? setup ? data (in or out) ? status (out or in) the user has to change the pipe token according to each stage. for control pipes only, the token is assigned a specific initial da ta toggle sequence: ? setup: data0 ? in: data1 ? out: data1 32.6.3.11 management of in pipes ? overview in packets are sent by the usb device contro ller upon in requests from the host. all the data can be read, acknowledging whether or not the bank is empty. ? detailed description the pipe and its descriptor in ram must be pre configured. the host can request data from the device in tw o modes, selected by writing to the in request mode bit in the pipe n in request register (upinrqn.inmode): ? when inmode is written to zero, the usbc will perform inrq in re quests before freezing the pipe. ? when inmode is written to one, the usbc will perf orm in requests as long as the pipe is not frozen by the user. the generation of in requests starts when t he pipe is unfrozen (upconn.pfreeze is zero). when the current bank is full, the rxini and fifo control (upstan.fifo con) bits will be set simultaneously. this triggers a pnint interrupt if the received in data interrupt enable bit (upconn.rxine) is one. rxini shall be cleared by softwa re to acknowledge the interrupt. this is done by writing a one to the received in data interrupt clear bit in the pipe n control clear register (upconnclr.rxinic), which does not affect the pipe fifo. the user reads the byte count of the current bank from the descriptor in ram (pn_pcksize_bk0/1.byte_count) to know how many bytes should be read. the user reads the in da ta from the ram and clears the fifo con bit to free the bank. this will also cause a switch to the next bank if the in endpoint is composed of multiple banks. the rxini and fifocon bits will be updated accordingly.
900 32117b?avr-03/11 at32uc3c rxini should always be cleared before cleari ng fifocon to avoid missing an rxini event. figure 32-19. example of an in pipe with one data bank figure 32-20. example of an in pipe with two data banks ? multi packet mode for in pipes see ?multi packet mode for out endpoints? on page 891 and just replace out endpoints with in pipe. 32.6.3.12 management of out pipes ? overview out packets are sent by the host. all the data can be written, acknowledging whether or not the bank is full. ? detailed description the pipe and its descriptor in ram must be pre configured. when the current bank is clear, the transmitted out data interrupt (txouti) and fifo control (upstan.fifocon) bits will be set simultaneously. this tr iggers a pnint inte rrupt if the trans- mitted out data interrupt enable bit (upconn.txoute) is one. in data (bank 0) ack rxini fifocon hw in data (bank 0) ack hw sw sw sw read data from cpu bank 0 read data from cpu bank 0 in data (bank 0) ack rxini fifocon hw in data (bank 1) ack sw sw read data from cpu bank 0 hw sw read data from cpu bank 1
901 32117b?avr-03/11 at32uc3c txouti shall be cleared by software to acknowledge the interrupt. this is done by writing a one to the transmitted out data interrupt clear bit (upconnclr.txoutic), which does not affect the pipe fifo. the user writes the out data to the bank refer enced to by the pepn descriptor and allows the usbc to send the data by writing a one to the fifo control clear (upconnclr.fifoconc) bit. this will also cause a switch to the next bank if the out pipe is comp osed of multiple banks. the txouti and fifocon bits will be updated accordingly txouti shall always be cleared before clearing fifocon to avoid missing an txouti event. note that if the user decides to switch to the suspend state (by writing a zero to uhcon.sofe) while a bank is ready to be sent, the usbc au tomatically exits this state and sends the data. figure 32-21. example of an out pipe with one data bank figure 32-22. example of an out pipe with two data banks and no bank switching delay out data (bank 0) ack txouti fifocon hw write data to cpu bank 0 sw sw sw sw out write data to cpu bank 0 out data (bank 0) ack txouti fifocon write data to cpu bank 0 sw sw sw sw write data to cpu bank 1 sw hw write data to cpu bank0 out data (bank 1) ack
902 32117b?avr-03/11 at32uc3c figure 32-23. example of an out pipe with two data banks and a bank switching delay ? multi packet mode for out pipes see section ?multi packet mode for in endpoints? on page 889 and just replace in endpoints with out pipe. 32.6.3.13 alternate pipe the user has the possibility to r un sequentially several logical pi pes on the same physical pipe. before switching pipe, the user should save the pipe context (upcfgn, upconn, upstan, and the pipe descriptor table). after switching pipe, the user should restore the pipe context, current bank number, and the cur- rent data toggle by using the upco nn.initdtgl and upconn.initbk bits. 32.6.3.14 data flow error this error exists only for isochronous and interrupt pipes for both in and out directions. it sets the errorflow interrupt (errorfi) bit in upstan, which triggers an pnint interrupt if the error- flow interrupt enable (errorfe) bit is one. the user can check the pn_ctr_sta_bk0/1.underf and overf bits in the pipe descriptor to see which current bank has been affected. ? an overflow can occur during an out stage if the host attempts to send data from an empty bank. the pipe descriptor pn_ctr_sta_bk0/1 .overf points out the bank from which the out data should have originated. if the u pstan.errorfi bit is cleared and a new transaction is su ccessful, the pn_ctr_sta_bk0/1 .overf bit will be cleared. ? an underflow can occur during an in stage if the device tries to send a packet while the bank is full. typically this occurs when a cpu is no t fast enough. the packet data is not written to the bank and is lost. the pipe descriptor pn_ctr_sta_bk0/1.underf points out which bank the out data was destined to. if upstan .underfi is zero and a new successful transaction occurs, pn_ctr_sta _bk0/1.underf will be cleared. 32.6.3.15 crc error this error exists only for isoc hronous in pipes. it sets the cr c error interrupt bit (crcerri), which triggers a pnint interrup t if the crc error interrupt enable bit (upconn.crcerre) is one. out data (bank 0) ack txouti fifocon write data to cpu bank 0 sw sw sw sw out data (bank 1) ack write data to cpu bank 1 sw hw write data to cpu bank0
903 32117b?avr-03/11 at32uc3c a crc error can occur during the in stage if the usbc detects a corrupted packet. the in packet will remain st ored in the bank and rxini will be set. the user can check the pn_ctr_sta_bk0/1.crcerr bit in the pipe descriptor to see which current bank has been affected. 32.6.3.16 interrupts there are two kinds of host interrupts: processing, i.e. their generation is part of the normal pro- cessing, and exception, i.e. errors not related to cpu exceptions. ? global interrupts the processing host global interrupts are: ? the device connection interrupt (dconni) ? the device disconnection interrupt (ddisci) ? the usb reset sent interrupt (rsti) ? the downstream resume sent interrupt (rsmedi) ? the upstream resume received interrupt (rxrsmi) ? the host start of frame interrupt (hsofi) ? the host wakeup interrupt (hwupi) ? the pipe n interrupt (pnint) there is no exception host global interrupt. ? pipe interrupts the processing host pipe interrupts are: ? the received in data interrupt (rxini) ? the transmitted out data interrupt (txouti) ? the transmitted setup interrupt (txstpi) ? the number of busy banks (nbusybk) interrupt the exception host pipe interrupts are: ? the errorflow interrupt (errorfi) ? the pipe error interrupt (perri) ? the naked interrupt (nakedi) ? the received stalled interrupt (rxstalldi) ? the crc error interrupt (crcerri)
904 32117b?avr-03/11 at32uc3c 32.7 user interface table 32-10. usbc register memory map offset register name access reset value 0x0000 device general control register udcon read/write 0x00000100 0x0004 device global interrupt register udint read-only 0x00000000 0x0008 device global interrupt clear register udintclr write-only 0x00000000 0x000c device global interrupt se t register udintset write-only 0x00000000 0x0010 device global interrupt enable register udinte read-only 0x00000000 0x0014 device global interrupt enable clear register udinteclr write-only 0x00000000 0x0018 device global interrupt enable set register udinteset write-only 0x00000000 0x001c endpoint enable/reset register uerst read/write 0x00000000 0x0020 device frame number register udfnum read-only 0x00000000 0x0100 + n*4 endpoint n configuration register uecfgn read/write 0x00000000 0x0130 + n*4 endpoint n status register uestan read-only 0x00000100 0x0160 + n*4 endpoint n status clear register uestanclr write-only 0x00000000 0x0190 + n*4 endpoint n status set register uestanset write-only 0x00000000 0x01c0 + n*4 endpoint n control register ueconn read-only 0x00000000 0x01f0 + n*4 endpoint n control set register ueconnset write-only 0x00000000 0x0220 + n*4 endpoint n control clear register ueconnclr write-only 0x00000000 0x0400 host general control register uhcon read/write 0x00000000 0x0404 host global interrupt register uhint read-only 0x00000000 0x0408 host global interrupt clear register uhintclr write-only 0x00000000 0x040c host global interrupt set register uhintset write-only 0x00000000 0x0410 host global interrupt enable register uhinte read-only 0x00000000 0x0414 host global interrupt enable cl ear register uhinteclr write-only 0x00000000 0x0418 host global interrupt enable set register uhinteset write-only 0x00000000 0x0041c pipe enable/reset register uprst read/write 0x00000000 0x0420 host frame number r egister uhfnum read/write 0x00000000 0x0500 + n*4 pipe n configuration register upcfgn read/write 0x00000000 0x0530 + n*4 pipe n status register upstan read-only 0x00000000 0x0560 + n*4 pipe n status clear register upstanclr write-only 0x00000000 0x0590 + n*4 pipe n status set register upstanset write-only 0x00000000 0x05c0 + n*4 pipe n control register upconn read-only 0x00000000 0x05f0 +n*4 pipe n control set register upconnset write-only 0x00000000 0x0620 + n*4 pipe n control clear register upconnclr write-only 0x00000000 0x0650 + n*4 pipe n in request register upinrqn read/write 0x00000001 0x0800 general control register usbcon read/write 0x03004000 0x0804 general status regi ster usbsta read-only 0x00000000
905 32117b?avr-03/11 at32uc3c note: 1. the reset values are device specific. please refer to the module configuration section at the end of this chapter. 0x0808 general status clear regi ster usbstaclr write-only 0x00000000 0x080c general status set regi ster usbstaset writ e-only 0x00000000 0x0818 ip version register uvers read-only - (1) 0x081c ip features register ufeatures read-only - (1) 0x0820 ip pb address size register uaddrsize read-only - (1) 0x0824 ip name register 1 uname1 read-only - (1) 0x0828 ip name register 2 uname2 read-only - (1) 0x082c usb finite state machine stat us register usbfsm read-only 0x00000009 0x0830 usb descriptor address udesc read/write 0x00000000 table 32-10. usbc register memory map offset register name access reset value
906 32117b?avr-03/11 at32uc3c 32.7.1 usb general registers 32.7.1.1 general control register name: usbcon access type: read/write offset: 0x0800 reset value: 0x03004000 ? uimod: usbc mode 0: the module is in usb host mode. 1: the module is in usb device mode. this bit has no effect when uide is one (usb_id input pin activated). this bit can be written to even if usbe is zero or frzclk is one. disabling the usbc (by writing a zero to the usbe bit) does not reset this bit. ? uide: usb_id pin enable 0: the usb mode (device/host) is selected from the uimod bit. 1: the usb mode (device/host) is selected from the usb_id input pin. this bit can be written to even if usbe is zero or frzclk is one. disabling the usbc (by writing a zero to the usbe bit) does not reset this bit. ? unlock: timer access unlock 0: the timpage and timvalue fields are locked. 1: the timpage and timvalue fields are unlocked. the timpage and timvalue fields can alwa ys be read, regardless of the unlock value. ? timpage: timer page this field contains the page value to access a special timer register. ? timvalue: timer value this field selects the timer value that is written to the special time register selected by timpage. see section 32.6.1.7 for details. ? usbe: usbc enable writing a zero to this bit will disable the usbc, usb transceiver , and usb clock inputs. this will over-ride frzclk settings bu t not affect the value. unless explicitly stated , all registers will become reset and read-only. writing a one to this bit will enable the usbc. 0: the usbc is disabled. 31 30 29 28 27 26 25 24 ------uimoduide 23 22 21 20 19 18 17 16 - unlock timpage - - timvalue 15 14 13 12 11 10 9 8 usbe frzclk vbuspo otgpade hnpreq srpreq srpsel vbushwc 76543210 stoe hnperre roleexe bcerre vberre srpe vbuste idte
907 32117b?avr-03/11 at32uc3c 1: the usbc is enabled. this bit can be written to even if frzclk is one. ? frzclk: freeze usb clock writing a zero to this bit will enable usb clock inputs. writing a one to this bit will disable usb clock inputs. the resume detection will remain active. unless explicitly stated, all registers will become read-only. 0: the clock inputs are enabled. 1: the clock inputs are disabled. this bit can be written to even if usbe is zero. ? vbuspo: vbus polarity 0: the usb_vbof output signal is in its default mode (active high). 1: the usb_vbof output signal is inverted (active low). this bit can be written even if usbe is zero or frzclk is one. disabling the usbc (by writing a zero to the usbe bit) does not reset this bit. ? otgpade: otg pad enable 0: the otg pad is disabled. 1: the otg pad is enabled. this bit can be written even if usbe is zero or frzclk is one. disabling the usbc (by writing a zero to the usbe bit) does not reset this bit. ? hnpreq: hnp request when the controller is in device mode: writing a zero to this bit has no effect. writing a one to this bit will initiate a hnp (host negotiation protocol). this bit is cleared when the controller has initiated an hnp. when the controller is in host mode: writing a zero to this bit will reject a hnp. writing a one to this bit will accept a hnp. ? srpreq: srp request writing a zero to this bit has no effect. writing a one to this bit will initiate an srp when the controller is in device mode. this bit is cleared when the controller has initiated an srp. ? srpsel: srp selection 0: data line pulsing is selected as srp method. 1: vbus pulsing is selected as srp method. ? vbushwc: vbus hardware control 0: the hardware control over the usb_vbo f output pin is enabled. the usbc resets the usb_vbof output pin when a vbus problem occurs. 1: the hardware control over t he usb_vbof output pin is disabled. ? stoe: suspend time-out interrupt enable 0: the suspend time-out interrupt (stoi) is disabled. 1: the suspend time-out interrupt (stoi) is enabled. ? hnperre: hnp error interrupt enable 0: the hnp error interrup t (hnperri) is disabled. 1: the hnp error interrupt (hnperri) is enabled. ? roleexe: role exchange interrupt enable 0: the role exchange interrupt (roleexi) is disabled. 1: the role exchange interrupt (roleexi) is enabled. ? bcerre: b-connection error interrupt enable 0: the b-connection error interrupt (bcerri) is disabled. 1: the b-connection error interrupt (bcerri) is enabled. ? vberre: vbus error interrupt enable 0: the vbus error interrupt (vberri) is disabled.
908 32117b?avr-03/11 at32uc3c 1: the vbus error interrupt (vberri) is enabled. ? srpe: srp interrupt enable 0: the srp interrupt (srpi) is disabled. 1: the srp interrupt (srpi) is enabled. ? vbuste: vbus transi tion interrupt enable 0: the vbus transition interrupt (vbusti) is disabled. 1: the vbus transition interrupt (vbusti) is enabled. ? idte: id transition interrupt enable 0: the id transition interrupt (idti) is disabled. 1: the id transition interrupt (idti) is enabled.
909 32117b?avr-03/11 at32uc3c 32.7.1.2 general status register register name: usbsta access type: read-only offset: 0x0804 reset value: 0x00000000 ? clkusable: generic clock usable this bit is cleared when the usb generic clock is not usable. this bit is set when the usb generic clock (that should be 48 mhz) is usable. ? speed: speed status this field is set according to the controller speed mode. ? vbus: vbus level this bit is cleared when the vbus line level is low, even if usbe is zero. this bit is set when the vbus line le vel is high, even if usbe is zero. this bit can be used in device mode to monito r the usb bus connection state of the application. ? id: usb_id pin state this bit is cleared when the usb_id level is low, even if usbe is zero. this bit is set when the usb_id level is high, even if usbe is zero. ? vbusrq: vbus request 0: the usb_vbof output pin is driven low to disable the vbus power supply generation. 1: the usb_vbof output pin is driven high to enable the vbus power supply generation. this bit is cleared when usbstaclr.vbusrqc is written to one or when a vbus error occurs while vbushwc is zero. this bit is set when usbstaset.vbusrqs is written to one. this bit should only be used in host mode. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - clkusable speed vbus id vbusrq - 76543210 stoi hnperri roleexi bcerri vberri srpi vbusti idti speed speed status 00 full-speed mode 01 reserved 10 low-speed mode 11 reserved
910 32117b?avr-03/11 at32uc3c ? stoi: suspend time-out interrupt this bit is cleared when the usbstaclr.stoic bit is written to one. this bit is set when a time-out error (more than 200ms) has b een detected after a suspend. this triggers a usb interrupt if stoe is one. this bit should only be used in host mode. ? hnperri: hnp error interrupt this bit is cleared when the usbstaclr.hnperric bit is written to one. this bit is set when an error has been detected during a hnp negotiation. this triggers a usb interrupt if hnperre is one. this bit should only be used in device mode. ? roleexi: role exchange interrupt this bit is cleared when the usbstaclr.roleexic bit is written to one. this bit is set when the usbc has successfully switched its mode because of an hnp negotiation (host to device or device to host). this triggers a usb interrupt if roleexe is one. ? bcerri: b-connection error interrupt this bit is cleared when the usbstaclr.bcerric bit is written to one. this bit is set when an error occurs during the b-conn ection. this triggers a usb interrupt if bcerre is one. this bit should only be used in host mode. ? vberri: vbus error interrupt this bit is cleared when the usbstaclr.vberric bit is written to one. this bit is set when a vbus drop has been detected. this triggers a usb interrupt if vberre is one. this bit should only be used in host mode. ? srpi: srp interrupt this bit is cleared when the usbstaclr.srpic bit is written to one. this bit is set when an srp has been detected. this triggers a usb interrupt if srpe is one. this bit should only be used in host mode. ? vbusti: vbus transition interrupt this bit is cleared when the usbstaclr.vbustic bit is written to one. this bit is set when a transition (high to low, low to high) has been detected on the usb_vbus pad. this triggers a usb interrupt if vbuste is one. this interrupt is generated even if the clock is frozen by the frzclk bit. ? idti: id transition interrupt this bit is cleared when the usbstaclr.idtic bit is written to one. this bit is set when a transition (high to low, low to high) has been detected on the usb_id input pin. this triggers a usb interrupt if idte is one. this interrupt is generated even if the clock is frozen by the frzclk bit.
911 32117b?avr-03/11 at32uc3c 32.7.1.3 general status clear register register name: usbstaclr access type: write-only offset: 0x0808 read value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in usbsta. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------vbusrqc- 76543210 stoic hnperric roleexic bcerr ic vberric srpic vbustic idtic
912 32117b?avr-03/11 at32uc3c 32.7.1.4 general status set register register name: usbstaset access type: write-only offset: 0x080c read value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in usbsta. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------vbusrqs- 76543210 stois hnperris roleexis bcerris vberris srpis vbustis idtis
913 32117b?avr-03/11 at32uc3c 32.7.1.5 version register register name: uvers access type: read-only offset: 0x0818 read value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
914 32117b?avr-03/11 at32uc3c 32.7.1.6 features register register name: ufeatures access type: read-only offset: 0x081c read value: - ? eptnbrmax: maximal number of pipes/endpoints this field indicates the number of hardware-implemented pipes/endpoints: 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - eptnbrmax
915 32117b?avr-03/11 at32uc3c 32.7.1.7 address size register register name: uaddrsize access type: read-only offset: 0x0820 read value: - ? uaddrsize: ip pb address size this field indicates the size of the pb address space reserved for the usbc ip interface. 31 30 29 28 27 26 25 24 uaddrsize[31:24] 23 22 21 20 19 18 17 16 uaddrsize[23:16] 15 14 13 12 11 10 9 8 uaddrsize[15:8] 76543210 uaddrsize[7:0]
916 32117b?avr-03/11 at32uc3c 32.7.1.8 ip name register 1 register name: uname1 access type: read-only offset: 0x0824 read value: - ? uname1: ip name part one this field indicates the first part of the ascii-encoded name of the usbc ip. 31 30 29 28 27 26 25 24 uname1[31:24] 23 22 21 20 19 18 17 16 uname1[23:16] 15 14 13 12 11 10 9 8 uname1[15:8] 76543210 uname1[7:0]
917 32117b?avr-03/11 at32uc3c 32.7.1.9 ip name register 2 register name: uname2 access type: read-only offset: 0x0828 read value: ? uname2: ip name part two this field indicates the second part of the ascii-encoded name of the usbc ip. 31 30 29 28 27 26 25 24 uname2[31:24] 23 22 21 20 19 18 17 16 uname2[23:16] 15 14 13 12 11 10 9 8 uname2[15:8] 76543210 uname2[7:0]
918 32117b?avr-03/11 at32uc3c 32.7.1.10 finite state machine status register register name: usbfsm access type: read-only offset: 0x082c read value: 0x00000009 ? drdstate: dual role device state this field indicates the state of the usbc. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - drdstate drdstate description 0 a_idle state: this is the start state for a-devices (when the id pin is 0) 1 a_wait_vrise: in this state, the a-device waits for the voltage on vbus to rise above the a- device vbus valid threshold (4.4 v). 2 a_wait_bcon: in this state, the a-device waits for the b-device to signal a connection. 3 a_host: in this state, the a-device th at operates in host mode is operational. 4 a_suspend: the a-device operating as a host is in the suspend mode. 5 a_peripheral: the a-device operates as a peripheral. 6 a_wait_vfall: in this state, the a-device wait s for the voltage on vbus to drop below the a- device session valid threshold (1.4 v). 7 a_vbus_err: in this state, the a-device waits for recovery of the over-current condition that caused it to enter this state. 8 a_wait_discharge: in this state, the a-device waits for the data usb line to discharge (100 us). 9 b_idle: this is the start state fo r b-device (when the id pin is 1). the usbc controller operates in device mode. 10 b_peripheral: in this state, the b-device acts as the peripheral. 11 b_wait_begin_hnp: in this state, the b-device is in suspend mode and waits until 3 ms before initiating the hnp protocol if requested.
919 32117b?avr-03/11 at32uc3c 12 b_wait_discharge: in this state, the b-device waits for the data usb line to discharge (100 us) before becoming host. 13 b_wait_acon: in this state, the b-device wait s for the a-device to signal a connect before becoming b-host. 14 b_host: in this state, the b-device acts as the host. 15 b_srp_init: in this state, the b-device attempts to start a session using the srp protocol. drdstate description
920 32117b?avr-03/11 at32uc3c 32.7.1.11 usb descriptor address register name: udesc access type: read-write offset: 0x0830 read value: - ? udesca: usb descriptor address this field contains the address of the usb descripto r. the three least significant bits are always zero. 31 30 29 28 27 26 25 24 udesca[31:24] 23 22 21 20 19 18 17 16 udesca[23:16] 15 14 13 12 11 10 9 8 udesca[15:8] 76543210 udesca[7:0]
921 32117b?avr-03/11 at32uc3c 32.7.2 usb device registers 32.7.2.1 device genera l control register register name: udcon access type: read/write offset: 0x0000 reset value: 0x00000100 ? gnak: global nak 0: normal mode. 1: a nak handshake is answered for each usb transaction r egardless of the current endpoint memory bank status. ? ls: low-speed mode force 0: the full-speed mode is active. 1: the low-speed mode is active. this bit can be written to even if usbe is zero or frzclk is one. disabling the usbc (by writing a zero to the usbe bit) does not reset this bit. ? rmwkup: remote wakeup writing a zero to this bit has no effect. writing a one to this bit will send an upstream resume to the host for a remote wakeup. this bit is cleared when the usbc receives a usb reset or once the upstream resume has been sent. ? detach: detach writing a zero to this bit will reconnect the device. writing a one to this bit will physically detach the device (disconnect internal pull-up resistor from dp and dm). ? adden: address enable writing a zero to this bit has no effect. writing a one to this bit will activate the uadd field (usb address). this bit is cleared when a usb reset is received. ? uadd: usb address this field contains the device address. this field is cleared when a usb reset is received. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------gnak- 15 14 13 12 11 10 9 8 ---ls--rmwkupdetach 76543210 adden uadd
922 32117b?avr-03/11 at32uc3c 32.7.2.2 device global interrupt register register name: udint access type: read-only offset: 0x0004 reset value: 0x00000000 note: 1. epnint bits are within th e range from ep0int to ep6int. ? epnint: endpoint n interrupt this bit is cleared when the interrupt source is serviced. this bit is set when an interrupt is triggered by the endpoint n (uestan, ueconn). this triggers a usb interrupt if epninte is one. ? uprsm: upstream resume interrupt this bit is cleared when the udintclr.uprsmc bit is written to one to acknowledge the interrupt (usb clock inputs must be enabled before). this bit is set when the usbc sends a resume signal called ?u pstream resume?. this triggers a usb interrupt if uprsme is one. ? eorsm: end of resume interrupt this bit is cleared when the udintclr.eorsmc bit is written to one to acknowledge the interrupt. this bit is set when the usbc detects a valid ?end of resume? signal initiated by the host. this triggers a usb interrupt if eorsme is one. ? wakeup: wakeup interrupt this bit is cleared when the udintclr.wakeupc bit is written to one to acknowledge the interrupt (usb clock inputs must be enabled before) or when the suspend (susp) interrupt bit is set. this bit is set when the usbc is reactiva ted by a filtered non-idle signal from the lines (not by an upstream resume). this triggers an interrupt if wakeupe is one. this interrupt is generated even if the clock is frozen by the frzclk bit. ? eorst: end of reset interrupt this bit is cleared when the udintclr.eorstc bit is written to one to acknowledge the interrupt. this bit is set when a usb ?end of reset? has been dete cted. this triggers a usb interrupt if eorste is one. ? sof: start of frame interrupt this bit is cleared when the udintclr.sofc bit is written to one to acknowledge the interrupt. this bit is set when a usb ?start of frame? pid (sof) has been de tected (every 1 ms). this triggers a usb interrupt if sofe is one. the fnum field is updated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - ep8int (1) ep7int (1) ep6int (1) ep5int (1) ep4int (1) 15 14 13 12 11 10 9 8 ep3int (1) ep2int (1) ep1int (1) ep0int - - - - 76543210 - uprsm eorsm wakeup eorst sof - susp
923 32117b?avr-03/11 at32uc3c ? susp: suspend interrupt this bit is cleared when the udintclr.suspc bit is written to one to acknowledge the interrupt or when the wakeup (wakeup) interrupt bit is set. this bit is set when a usb ?suspend? idle bus state has been det ected for 3 frame periods (j stat e for 3 ms). this triggers a usb interrupt if suspe is one.
924 32117b?avr-03/11 at32uc3c 32.7.2.3 device global interrupt clear register register name: udintclr access type: write-only offset: 0x0008 read value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in udint. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - uprsmc eorsmc wakeupc eorstc sofc - suspc
925 32117b?avr-03/11 at32uc3c 32.7.2.4 device global interrupt set register register name: udintset access type: write-only offset: 0x000c read value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in udint, which may be useful for test or debug purposes . these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - uprsms eorsms wakeups eorsts sofs - susps
926 32117b?avr-03/11 at32uc3c 32.7.2.5 device global interrupt enable register register name: udinte access type: read-only offset: 0x0010 reset value: 0x00000000 note: 1. epninte bits are within the range from ep0inte to ep6inte. 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in udinteclr is written to one. a bit in this register is set when the corresponding bit in udinteset is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - ep8inte (1) ep7inte (1) ep6inte (1) ep5inte (1) ep4inte (1) 15 14 13 12 11 10 9 8 ep3inte (1) ep2inte (1) ep1inte (1) ep0inte---- 76543210 - uprsme eorsme wakeupe eorste sofe - suspe
927 32117b?avr-03/11 at32uc3c 32.7.2.6 device global interrupt enable clear register register name: udinteclr access type: write-only offset: 0x0014 read value: 0x00000000 note: 1. epnintec bits are within th e range from ep0intec to ep6intec. writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in udinte. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - ep8intec (1) ep7intec (1) ep6intec (1) ep5intec (1) ep4intec (1) 15 14 13 12 11 10 9 8 ep3intec (1) ep2intec (1) ep1intec (1) ep0intec - - - - 76543210 - uprsmec eorsmec wakeupec eorstec sofec - suspec
928 32117b?avr-03/11 at32uc3c 32.7.2.7 device global interrupt enable set register register name: udinteset access type: write-only offset: 0x0018 read value: 0x00000000 note: 1. epnintes bits are within the range from ep0intes to ep6intes. writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in udinte. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - ep8intes (1) ep7intes (1) ep6intes (1) ep5intes (1) ep4intes (1) 15 14 13 12 11 10 9 8 ep3intes (1) ep2intes (1) ep1intes (1) ep0intes - - - - 76543210 - uprsmes eorsmes wakeupes eorstes sofes - suspes
929 32117b?avr-03/11 at32uc3c 32.7.2.8 endpoint enable/reset register register name: uerst access type: read/write offset: 0x001c reset value: 0x00000000 ? epenn: endpoint n enable note: 1. epenn bits are within th e range from epen0 to epen6. writing a zero to this bit will disable the endpoint n (usb requests will be ignored), and resets the endpoints registers (uecf gn, uestan, ueconn), but not the endpoint confi guration (epbk, epsize, epdir, eptype). writing a one to this bit will enable the endpoint n. 0: the endpoint n is disabled. 1: the endpoint n is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - - - epen8 (1) 76543210 epen7 (1) epen6 (1) epen5 (1) epen4 (1) epen3 (1) epen2 (1) epen1 (1) epen0
930 32117b?avr-03/11 at32uc3c 32.7.2.9 device frame number register register name: udfnum access type: read-only offset: 0x0020 reset value: 0x00000000 ? fncerr: frame number crc error this bit is cleared upon receiving a usb reset. this bit is set when a corrupted frame number is received. th is bit and the sof interrupt bit are updated at the same time. ? fnum: frame number this field is cleared upon receiving a usb reset. this field contains the 11-bit frame number info rmation, as provided from the last sof packet. fnum is updated even if a corrupted sof is received. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 fncerr - fnum[10:5] 76543210 fnum[4:0] - - -
931 32117b?avr-03/11 at32uc3c 32.7.2.10 endpoint n configuration register register name: uecfgn, n in [0..6] access type: read/write offset: 0x0100 + (n * 0x04) reset value: 0x00000000 ? eptype: endpoint type this field selects the endpoint type: this field is cleared upon receiving a usb reset. ? epdir: endpoint direction 0: the endpoint direction is out. 1: the endpoint direction is in (nor for control endpoints). this bit is cleared upon receiving a usb reset. ? epsize: endpoint size this field determines the size of each endpoint bank: 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - eptype - - epdir 76543210 - epsize - epbk -- eptype endpoint type 0 0 control 0 1 isochronous 10bulk 1 1 interrupt epsize endpoint size 0 0 0 8 bytes 00116 bytes 01032 bytes 01164 bytes 1 0 0 128 bytes
932 32117b?avr-03/11 at32uc3c this field is cleared upon receiving a usb reset (except for the endpoint 0). ? epbk: endpoint banks this bit selects the number of banks for the endpoint: 0: single-bank endpoint 1: double-bank endpoint for control endpoints, a single-bank endpoint shall be selected. this field is cleared upon receiving a usb reset (except for the endpoint 0). 1 0 1 256 bytes 1 1 0 512 bytes 1 1 1 1024 bytes epsize endpoint size
933 32117b?avr-03/11 at32uc3c 32.7.2.11 endpoint n status register register name: uestan, n in [0..6] access type: read-only 0x0100 offset: 0x0130 + (n * 0x04) reset value: 0x00000000 ? ctrldir: control direction writing a zero or a one to this bit has no effect. this bit is cleared after a setup packet to indicate that the following packet is an out packet. this bit is set after a setup packet to indica te that the following packet is an in packet. ? currbk: current bank this bit is set for non-control endpoints, indicating the current bank: this field may be updated one clock cycle after the rwall bit changes, so the user should not poll this field as an interrupt b it. ? nbusybk: number of busy banks this field is set to indicate the number of busy banks: 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - - - ctrldir - 15 14 13 12 11 10 9 8 currbk nbusybk ramaceri - dtseq 76543210 - stalledi/ crcerri - nakini nakouti rxstpi/ errorfi rxouti txini currbk current bank 00bank0 01bank1 10reserved 11reserved nbusybk number of busy banks 0 0 0 (all banks free) 011 102 11reserved
934 32117b?avr-03/11 at32uc3c for in endpoints, this indicates the number of banks filled by the user and ready for in transfers. when all banks are free an epnint interrupt will be triggered if nbusybke is one. for out endpoints, this indicates the number of banks filled by out transactions from the host. when all banks are busy an epnint interrupt will be triggered if nbusybke is one. ? ramaceri: ram access error interrupt this bit is cleared when the ramaceric bit is written to one, acknowledging the interrupt. this bit is set when a ram access underflow error occurs during an in data stage. ? dtseq: data toggle sequence this field is set to indicate the pid of the current bank: for in transfers, this indicates the data toggle seq uence that will be used for the next packet to be sent. for out transfers, this value indicates the data toggle sequence of the data received in the current bank. ? stalledi: stalled interrupt this bit is cleared when the stalledic bit is written to one, acknowledging the interrupt. this bit is set when a stall handshake has been sent and triggers an epnint interrupt if stallede is one. ? crcerri: crc error interrupt this bit is cleared when the crcerric bit is written to one, acknowledging the interrupt. this bit is set when a crc error has been detected in an isochronous out endpoint bank, and triggers an epnint interrupt if crcerre is one. ? nakini: naked in interrupt this bit is cleared when the nakinic bit is written to one, acknowledging the interrupt. this bit is set when a nak handshake has been sent in response to an in request from the host, and triggers an epnint interrupt if nakine is one. ? nakouti: naked out interrupt this bit is cleared when the nakoutic bit is written to one, acknowledging the interrupt. this bit is set when a nak handshake has been sent in response to an out request from the host, and triggers an epnint interrupt if nakoute is one. ? errorfi: isochronous error flow interrupt this bit is cleared when the errorfic bit is written to one, acknowledging the interrupt. this bit is set, for isochronous in/out endpoints, when an errorflow (underflow or overflow) error occurs, and triggers an epnint interrupt if errorfe is one. an underflow can occur during in stage if the host attempts to read from an empty bank. a zero-length packet is then automatically sent by the usbc. an overflow can also occur during out stage if the host sends a packet while the bank is already full, resulting in the packet being lost. this is typically due to a cpu not being fast enough. this bit is inactive (cleared) for bulk and interrupt in/out endpoints and it means rxstpi for control endpoints. ? rxstpi: received setup interrupt this bit is cleared when the rxstpic bit is written to one, acknowledging the interrupt and freeing the bank. this bit is set, for control endpoints, to signal that the curre nt bank contains a new valid setup packet, and triggers an epni nt interrupt if rxstpe is one. this bit is inactive (cleared) for bulk and interrupt in/out endpoints and it means underfi for isochronous in/out endpoints. ? rxouti: received out data interrupt this bit is cleared when the rxoutic bit is written to one, acknowledging the interrupt. for control endpoints, it releases the bank. for other endpoint types, the user should clear the fifoco n bit to free the bank. rxouti shall always be cleared before clearing fifocon to avoid missing an interrupt. dtseq data toggle sequence 00data0 01data1 1xreserved
935 32117b?avr-03/11 at32uc3c this bit is set, for control endpoints, when the current bank c ontains a bulk out packet (data or status stage). this triggers an epnint interrupt if rxoute is one. this bit is set for isochronous, bulk and, interrupt out endpoints, at the same time as fifocon when the current bank is full. this triggers an epnint interrupt if rxoute is one. this bit is inactive (cleared) for isochronous, bulk and interrupt in endpoints. ? txini: transmitted in data interrupt this bit is cleared when the txinic bit is written to one, acknowledging the interrupt. for control endpoints, this will send t he packet. for other endpoint types, the user should clear the fifocon to allow the usbc to send the data. txini shall always be cleared before clearing fifocon to avoid missing an interrupt. this bit is set for control endpoints, when the current bank is ready to accept a new in packet. this triggers an epnint interr upt if txine is one. this bit is set for isochronous, bulk and interrupt in endpoints, at the same time as fifocon when the current bank is free. this triggers an epnint interrupt if txine is one. this bit is inactive (cleared) for isochronous, bulk and interrupt out endpoints.
936 32117b?avr-03/11 at32uc3c 32.7.2.12 endpoint n status clear register register name: uestanclr, n in [0..6] access type: write-only offset: 0x0160 + (n * 0x04) read value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in uesta. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - ramaceric - - - 76543210 - stalledic/ crcerric - nakinic nakoutic rxstpic/ errorfic rxoutic txinic
937 32117b?avr-03/11 at32uc3c 32.7.2.13 endpoint n status set register register name: uestanset, n in [0..6] access type: write-only offset: 0x0190 + (n * 0x04) read value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in uesta. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - nbusybks ramaceris - - 76543210 - stalledis/ crcerris - nakinis nakoutis rxstpis/ errorfis rxoutis txinis
938 32117b?avr-03/11 at32uc3c 32.7.2.14 endpoint n control register register name: ueconn, n in [0..6] access type: read-only offset: 0x01c0 + (n * 0x04) reset value: 0x00000000 ? busy0e: busy bank0 enable this bit is cleared when the busy0c bit is written to one. this bit is set when the busy0es bit is wr itten to one. this will set the bank 0 as ?busy?. all transactions, except setup, destined to this bank will be rejected (i.e: nak token will be answered). ? busy1e: busy bank1 enable this bit is cleared when the busy1c bit is written to one. this bit is set when the busy1es bit is wr itten to one. this will set the bank 1 as ?busy?. all transactions, except setup, destined to this bank will be rejected (i.e: nak token will be answered). ? stallrq: stall request this bit is cleared when a new setup packet is received or when the stallrqc bit is written to zero. this bit is set when the stallrqs bit is written to one, requesting a stall handshake to be sent to the host. ? rstdt: reset data toggle the data toggle sequence is cleared when the rstdts bit is written to one (i.e., data0 data toggle sequence will be selected for the next sent (in endpoints) or received (out endpoints) packet. this bit is always read as zero. ? fifocon: fifo control for control endpoints: the fifocon and rwall bits are irrelevant. the software shal l therefore never use them for these endpoints. when read, their value is always 0. for in endpoints: this bit is cleared when the fifoconc bit is written to one, sending the fifo data and switching to the next bank. this bit is set simultaneously to txini, when the current bank is free. for out endpoints: this bit is cleared when the fifoconc bit is written to one, freeing the current bank and switching to the next. this bit is set simultaneously to rxini, when the current bank is full. 31 30 29 28 27 26 25 24 - - - - - - busy1e busy0e 23 22 21 20 19 18 17 16 - - - - stallrq rstdt - - 15 14 13 12 11 10 9 8 - fifocon killbk nbusybke ramacere - - 76543210 - stallede/ crcerre - nakine nakoute rxstpe/ errorfe rxoute txine
939 32117b?avr-03/11 at32uc3c ? killbk: kill in bank this bit is cleared by hardware after the completion of the ?kill packet procedure?. this bit is set when the killbks bit is written to one, killing the last written bank. the user shall wait for this bit to be cleared before trying to process another in packet. caution: the bank is cleared when the ?kill packe t? procedure is completed by the usbc core: if the bank is really killed, the nbusybk field is decremented. if the bank sent instead of kill ed (in transfer), the nbusybk field is decremented and the txini flag is se t. this specific cas e can occur if an in token comes while the user tries to kill the bank. note: if two banks are ready to be sent, the above specific case will not occur, since the first bank is sent (in transfer) whi le the last bank is killed. ? nbusybke: number of bu sy banks interrupt enable this bit is cleared when the nbusybkec bit is written to zero, disabling the number of busy banks interrupt (nbusybk). this bit is set when the nbusybkes bi t is written to one, en abling the number of busy banks interrupt (nbusybk). ? ramacere: ramacer interrupt enable this bit is cleared when the ramacerec bit is written to one, disabling the ramacer interrupt (ramaceri). this bit is set when the ramaceres bit is written to one, enabling the ramacer interrupt (ramaceri). ? stallede: stalled interrupt enable this bit is cleared when the stalledec bit is writt en to one, disabling the stalled interrupt (stalledi). this bit is set when the stalledes bit is written to one, enabling the stalled interrupt (stalledi). ? crcerre: crc error interrupt enable this bit is cleared when the crcerrec bit is writte n to one, disabling the crc error interrupt (crcerri). this bit is set when the crcerres bit is written to one, enabling the crc error interrupt (crcerri). ? nakine: naked in interrupt enable this bit is cleared when the nakinec bit is writte n to one, disabling the naked in interrupt (nakini). this bit is set when the nakines bit is written to one, enabling the naked in interrupt (nakini). ? nakoute: naked out interrupt enable this bit is cleared when the nakoutec bit is written to one, disabling the naked out interrupt (nakouti). this bit is set when the nakoutes bit is written to one, enabling the naked out interrupt (nakouti). ? rxstpe: received set up interrupt enable this bit is cleared when the rxstpec bit is written to one, disabling the received setup interrupt (rxstpi). this bit is set when the rxstpes bit is written to one, enabling the received setup interrupt (rxstpi). ? errorfe: errorflow interrupt enable this bit is cleared when the errorfec bit is written to one, disabling the underflow interrupt (errorfi). this bit is set when the errorfes bit is written to one, enabling the underflow interrupt (errorfi). ? rxoute: received out data interrupt enable this bit is cleared when the rxoutec bit is written to one, di sabling the received out data interrupt (rxout). this bit is set when the rxoutes bit is written to one, enabling the received out data interrupt (rxout). ? txine: transmitted in data interrupt enable this bit is cleared when the txinec bit is written to one, disabling the tr ansmitted in data interrupt (txini). this bit is set when the txines bit is written to on e, enabling the transmitted in data interrupt (txini).
940 32117b?avr-03/11 at32uc3c 32.7.2.15 endpoint n control clear register register name: ueconnclr, n in [0..6] access type: write-only offset: 0x0220 + (n * 0x04) read value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in ueconn. these bits always read as zero. 31 30 29 28 27 26 25 24 - - - - - - busy1ec busy0ec 23 22 21 20 19 18 17 16 - - - - stallrqc - - - 15 14 13 12 11 10 9 8 - fifoconc - nbusybkec ramacerec - -- 76543210 - stalledec/ crcerrec - nakinec nakoutec rxstpec/ errorfec rxoutec txinec
941 32117b?avr-03/11 at32uc3c 32.7.2.16 endpoint n control set register register name: ueconnset, n in [0..6] access type: write-only offset: 0x01f0 + (n * 0x04) read value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in ueconn. these bits always read as zero. 31 30 29 28 27 26 25 24 - - - - - - busy1es busy0es 23 22 21 20 19 18 17 16 - - - - stallrqs rstdts - - 15 14 13 12 11 10 9 8 - - killbks nbusybkes ramaceres --- 76543210 - stalledes/ crcerres - nakines nakoutes rxstpes/ errorfes rxoutes txines
942 32117b?avr-03/11 at32uc3c 32.7.3 usb host registers 32.7.3.1 host general control register register name: uhcon access type: read/write offset: 0x0400 reset value: 0x00000000 ? ? ? resume: send usb resume writing a zero to this bit has no effect. writing a one to this bit will generate a usb resume on the usb bus. this bit should only be done when the start of frame generation is enabled (sofe bit is one). this bit is cleared when the usb resume has been sent or when a usb reset is requested. ? reset: send usb reset writing a zero to this bit might be useful when a device discon nection is detected (uhint.ddisci is one) while a usb reset is being sent. writing a one to this bit will generate a usb reset on the usb bus. this bit is cleared when the usb reset has been sent. ? sofe: start of frame generation enable writing a zero to this bit will disable the sof generation and to leave the usb bus in idle state. writing a one to this bit will generate sof on the usb bus in full speed mode and keep it alive in low speed mode. this bit is set when a usb reset is requested or an up stream resume interrupt is detected (uhint.rxrsmi). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - resume reset sofe 76543210 --------
943 32117b?avr-03/11 at32uc3c 32.7.3.2 host global interrupt register register name: uhint access type: read-only offset: 0x0404 reset value: 0x00000000 note: 1. pnint bits are within the range from p0int to p6int. ? pnint: pipe n interrupt this bit is cleared when the interrupt source is served. this bit is set when an interrupt is triggered by the endpoint n (upstan). this triggers a usb interrupt if the corresponding p ipe interrupt enable bit is one (uhinte register). ? hwupi: host wakeup interrupt this bit is cleared when the hwupic bit is written to one. this bit is set when: - the host controller is in the suspend mode (sofe is ze ro) and an upstream resume from the peripheral is detected. - the host controller is in the suspend mode (sof e is zero) and a peripheral disconnection is detected. - the host controller is in the idle state (vbusrq is zero, no vbus is generated), and an srp event initiated by the peripheral is detected (usbsta. srpi is one). this interrupt is generated even if the clock is frozen by the frzclk bit. ? hsofi: host start of frame interrupt this bit is cleared when the hsofic bit is written to one. this bit is set when a sof is issued by the host controller. this triggers a usb interrupt when hsofe is one. when using the host controller in low speed mode, this bit is also set when a keep-alive is sent. ? rxrsmi: upstream resu me received interrupt this bit is set when an upstream resume has been received from the device. this bit is cleared when the rxrsmic is written to one. ? rsmedi: downstream resume sent interrupt this bit is cleared when the rsmedic bit is written to one. this bit set when a downstream resume has been sent to the device. ? rsti: usb reset sent interrupt this bit is cleared when the rstic bit is written to one. this bit is set when a usb reset has been sent to the device. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------p8int (1) 15 14 13 12 11 10 9 8 p7int (1) p6int (1) p5int (1) p4int (1) p3int (1) p2int (1) p1int (1) p0int 76543210 - hwupi hsofi rxrsmi rsmedi rsti ddisci dconni
944 32117b?avr-03/11 at32uc3c ? ddisci: device disconnection interrupt this bit is cleared when the ddiscic bit is written to one. this bit is set when the device has been removed from the usb bus. ? dconni: device conn ection in terrupt this bit is cleared when the dconnic bit is written to one. this bit is set when a new device has been connected to the usb bus.
945 32117b?avr-03/11 at32uc3c 32.7.3.3 host global interrupt clear register register name: uhintclr access type: write-only offset: 0x0408 read value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in uhint. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - hwupic hsofic rxrsmic rsme dic rstic ddiscic dconnic
946 32117b?avr-03/11 at32uc3c 32.7.3.4 host global interrupt set register register name: uhintset access type: write-only offset: 0x040c read value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in uhint. these bits always read as zero. 31 30 29 28 27 26 25 24 ------ - 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - hwupis hsofis rxrsmis rs medis rstis ddiscis dconnis
947 32117b?avr-03/11 at32uc3c 32.7.3.5 host global interrupt enable register register name: uhinte access type: read-only offset: 0x0410 reset value: 0x00000000 note: 1. pninte bits are within th e range from p0inte to p6inte. ? pninte: pipe n interrupt enable this bit is cleared when the pnintec bit is written to one. this will disable the pipe n interrupt (pnint). this bit is set when the pnintes bit is written to one. this will enable the pipe n interrupt (pnint). ? hwupie: host wakeup interrupt enable this bit is cleared when the hwupiec bit is written to one. this will disabl e the host wakeup interrupt (hwupi). this bit is set when the hwupies bit is written to one. this will enable the host wakeup interrupt (hwupi). ? hsofie: host start of frame interrupt enable this bit is cleared when the hsofiec bit is written to one. this will disable the host start of frame interrupt (hsofi). this bit is set when the hsofies bit is written to one. this will enable the host start of frame interrupt (hsofi). ? rxrsmie: upstream resume received interrupt enable this bit is cleared when the rxrsmiec bit is written to on e. this will disable the downstream resume interrupt (rxrsmi). this bit is set when the rxrsmies bit is written to one. this will enable the upstream resume received interrupt (rxrsmi). ? rsmedie: downstream resu me sent interrupt enable this bit is cleared when the rsmediec bit is written to on e. this will disable the downstream resume interrupt (rsmedi). this bit is set when the rsmedies bit is written to one. this will enable the downstream resume interrupt (rsmedi). ? rstie: usb reset sent interrupt enable this bit is cleared when the rstiec bit is written to one. this will disable the usb reset sent interrupt (rsti). this bit is set when the rsties bit is written to one. this will enable the usb reset sent interrupt (rsti). ? ddiscie: device discon nection interrupt enable this bit is cleared when the ddisciec bit is written to one. this will disable the device disconnection interrupt (ddisci). this bit is set when the ddiscies bit is written to one. this will enable the device disconnection interrupt (ddisci). ? dconnie: device connection interrupt enable this bit is cleared when the dconniec bit is written to on e. this will disable the device connection interrupt (dconni). this bit is set when the dconnies bit is written to one. th is will enable the device connection interrupt (dconni). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------p8inte (1) 15 14 13 12 11 10 9 8 p7inte (1) p6inte (1) p5inte (1) p4inte (1) p3inte (1) p2inte (1) p1inte (1) p0inte 76543210 - hwupie hsofie rxrsmie rs medie rstie ddiscie dconnie
948 32117b?avr-03/11 at32uc3c 32.7.3.6 host global interrupt enable clear register register name: uhinteclr access type: write-only offset: 0x0414 read value: 0x00000000 note: 1. pnintec bits are within t he range from p0intec to p6intec. writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in uhinte. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------p8intec (1) 15 14 13 12 11 10 9 8 p7intec (1) p6intec (1) p5intec (1) p4intec (1) p3intec (1) p2intec (1) p1intec (1) p0intec 76543210 - hwupiec hsofiec rxrsmiec rsmediec rstiec ddisciec dconniec
949 32117b?avr-03/11 at32uc3c 32.7.3.7 host global interrupt enable set register register name: uhinteset access type: write-only offset: 0x0418 read value: 0x00000000 note: 1. pnintes bits are within the range from p0intes to p6intes. writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in uhint. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------p8intes (1) 15 14 13 12 11 10 9 8 p7intes (1) p6intes (1) p5intes (1) p4intes (1) p3intes (1) p2intes (1) p1intes (1) p0intes 76543210 - hwupies hsofies rxrsmies rsmedies rsties ddiscies dconnies
950 32117b?avr-03/11 at32uc3c 32.7.3.8 pipe enable/reset register register name: uprst access type: read/write offset: 0x0041c reset value: 0x00000000 note: 1. penn bits are within the range from pen0 to pen6. ? penn: pipe n enable writing a zero to this bit will disable the pipe n, forcing the pipe to an inactive state and resetting the pipe registers (upc fgn, upstan, and upconn). writing a one to this bit will enable the pipe n. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------pen8 (1) 76543210 pen7 (1) pen6 (1) pen5 (1) pen4 (1) pen3 (1) pen2 (1) pen1 (1) pen0
951 32117b?avr-03/11 at32uc3c 32.7.3.9 host frame number register register name: uhfnum access type: read/write offset: 0x0420 reset value: 0x00000000 ? flenhigh: frame length this field contains the 8 high-order bits of the 14-bits internal frame counter (frame counter at 12mhz, counter length is 1200 0 to ensure a sof generation every 1 ms). ? fnum: frame number this field contains the current sof number. this field can be written by software to initialize a new frame nu mber value. in this case, at the next sof, the fnum field tak es its new value 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 flenhigh 15 14 13 12 11 10 9 8 - - fnum[10:5] 76543210 fnum[4:0] - - -
952 32117b?avr-03/11 at32uc3c 32.7.3.10 pipe n configuration register register name: upcfgn, n in [0..6] access type: read/write offset: 0x0500 + (n * 0x04) reset value: 0x00000000 ? binterval: binterval parameter this field corresponds to the bus access period of the pipe. for interrupt pipe, this field corresponds to the desired period from 1 ms to 255 ms. for isochronous pipe, this field corresponds to the desired period calculated as this: 2 (binterval) * 1 ms. for bulk or control pipe, this field corresponds to the desired period from 1 ms to 255 ms. this field is cleared upon sending a usb reset. ? ptype: pipe type this field contains the pipe type. this field is cleared upon sending a usb reset. ? ptoken: pipe token this field contains the endpoint token. 31 30 29 28 27 26 25 24 binterval 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - ptype - - ptoken 76543210 - psize - pbk -- ptype pipe type 0 0 control 0 1 isochronous 10bulk 1 1 interrupt ptoken endpoint direction 00 setup 01 in 10 out 11 reserved
953 32117b?avr-03/11 at32uc3c ? psize: pipe size this field contains the size of each pipe bank. this field is cleared upon sending a usb reset. ? pbk: pipe banks this bit selects the number of banks for the pipe. 0: single-bank pipe 1: double bank pipe for control endpoints, a single-bank pipe should be selected. this field is cleared upon sending a usb reset. psize endpoint size 0 0 0 8 bytes 00116 bytes 01032 bytes 01164 bytes 1 0 0 128 bytes 1 0 1 256 bytes 1 1 0 512 bytes 1 1 1 1024 bytes
954 32117b?avr-03/11 at32uc3c 32.7.3.11 pipe n status register register name: upstan, n in [0..6] access type: read-only offset: 0x0530 + (n * 0x04) reset value: 0x00000000 ? currbk: current bank for non-control pipe, this field indicates the number of the current bank. this field may be updated 1 clock cycle after the rwall bit changes, so the user should not poll this field for an interrupt. ? nbusybk: number of busy banks this field indicates the number of busy bank. for out pipe, this field indicates the number of busy bank(s), filled by the user, ready for out transfer. when all banks are busy, this triggers an pnint in terrupt if upconn.nbusybke is one. for in pipe, this field indicates the number of busy bank(s) filled by in transaction from the device. when all banks are free, this triggers an pnint interrup t if upconn.nbusybke is one. ? ramaceri: ram access error interrupt this bit is cleared when the ramaceric bit is written to one. this bit is set when a ram access underflow error occurs during in data stage. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - currbk nbusybk - ramaceri dtseq 76543210 - rxstalldi/ crcerri errorfi nakedi perri txstpi txouti rxini currbk current bank 00bank0 01bank1 nbusybk number of busy bank 0 0 all banks are free. 0 1 1 busy bank 1 0 2 busy banks 11reserved
955 32117b?avr-03/11 at32uc3c ? dtseq: data toggle sequence this field indicates the data pid of the current bank. for out pipes, this field indicates the data toggle of the next packet that will be sent. for in pipes, this field indicates the data toggle of the received packet stored in the current bank. ? rxstalldi: received stalled interrupt this bit is cleared when the rxstalldic bit is written to one. this bit is set, for all endpoints (except isochronous), when a stall handshake has been received on the current bank of the pipe. the pipe is automatically frozen. this triggers an interrupt if the rxstalle bit is one. ? crcerri: crc error interrupt this bit is cleared when the crcerric bit is written to one. this bit is set, for isochronous endpoint, when a crc error occurs on the current bank of the pipe. this triggers an interrupt if the txstpe bit is one. ? errorfi: errorflow interrupt this bit is cleared when the errorfic bit is written to one. this bit is set: - for isochronous and interrupt in/out pipes, when an error flow occurs. this triggers an interrupt if the errorfie bit is one. - for isochronous or interrupt out pipes, when a transaction under flow occurs in the current pipe. i.e, the pipe can?t send the out data packet in time because the current bank is not ready. - for isochronous or interrupt in pipes, when a transaction flow er ror occurs in the current pipe. i.e, the current bank of the pipe is not free when a new in usb packet is received. this packet is not stored in the bank. for interrupt pipes, the overflowed packet is acked to respect the usb standard. ? nakedi: naked interrupt this bit is cleared when the nakedic bit is written to one. this bit is set when a nak has been received on the current bank of the pipe. this trig gers an interrupt if the nakede bit is o ne. ? perri: pipe error interrupt this bit is cleared when the perric bit is written to one. this bit is set when an error occurs on the current bank of t he pipe. this triggers an interrupt if the perre bit is set. refer s to the persta structure of the pipe descriptor ( figure 32-9 ) to determine the source of the error. ? txstpi: transmitted setup interrupt this bit is cleared when the txstpic bit is written to one. this bit is set, for control endpoints, when the current setup bank is free and can be filled. this triggers an interrupt if th e txstpe bit is one. ? txouti: transmitted out data interrupt this bit is cleared when the txoutic bit is written to one. this bit is set when the current out bank is free and can be filled. this triggers an interrupt if the txoute bit is one. ? rxini: received in data interrupt this bit is cleared when the rxinic bit is written to one. this bit is set when a new usb message is stored in the current bank of the pipe. this triggers an interrupt if the rxine bit i s one. dtseq data toggle sequence 00data0 01data1 10reserved 11reserved
956 32117b?avr-03/11 at32uc3c 32.7.3.12 pipe n status clear register register name: upstanclr, n in [0..6] access type: write-only offset: 0x0560 + (n * 0x04) read value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in upstan. these bits always read as zero. 31 30 29 28 27 26 25 24 - - ------ 23 22 21 20 19 18 17 16 - - ------ 15 14 13 12 11 10 9 8 - - - - - ramaceric - - 76543210 - rxstalldic/ crcerric errorfic nakedic perric t xstpic txoutic rxinic
957 32117b?avr-03/11 at32uc3c 32.7.3.13 pipe n status set register register name: upstanset, n in [0..6] access type: write-only offset: 0x0590 + (n * 0x04) read value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in upstan. these bits always read as zero. 31 30 29 28 27 26 25 24 - - ------ 23 22 21 20 19 18 17 16 - - ------ 15 14 13 12 11 10 9 8 - - - - - ramaceris - - 76543210 - rxstalldis/ crcerris errorfic nakedis perri s txstpis txoutis rxinis
958 32117b?avr-03/11 at32uc3c 32.7.3.14 pipe n control register register name: upconn, n in [0..6] access type: read-only offset: 0x05c0 + (n * 0x04) reset value: 0x00000000 ? initbk: bank initialization this bit is always read as zero. if the user writes a one to the init bkc bit, this will set the current bank to bank0 value for the current pipe. if the user writes a one to the initbks bit, this will set the current bank to bank1 value for the current pipe. this may be useful to restore a pipe to manage alternate pipes on the same physical pipe. ? inittgl: data toggle initialization this bit is always read as zero. if the user writes a one to the inittglc bit, this will set the data toggle to data0 value for the current pipe. if the user writes a one to the inittgls bit, this will set the data toggle to data1 value for the current pipe. this may be useful to restore a pipe to manage alternate pipes on the same physical pipe. ? pfreeze: pipe freeze this bit is cleared when the pfreezec bit is writt en to one. this will enable the pipe request generation. this bit is set when the pfreezes bit is written to one or when the pipe is not configured or when a stall handshake has been received on this pipe, or when inrq in requests have b een processed, or after a pipe enable (uprst.pen rising). this will freeze the pipe requests generation. if the user clears the pfrfeezec bit while a transaction is on going on the usb bus, the transaction will be properly completed and then the pfreeze bit will be cleared. ? fifocon: fifo control for out and setup pipes: this bit is cleared when the fifoconc bit is written to one. this will send the fifo data and switch the bank. this bit is set when the current bank is free , at the same time than txouti or txstpi. for in pipes: this bit is cleared when the fifoconc bit is written to one. this will free the current bank and switch to the next bank. this bit is set when a new in message is stored in the current bank, at the same time than rxini. ? nbusybke: number of bu sy banks interrupt enable this bit is cleared when the nbusybkec bit is written to one. this will disable the transmitted in data interrupt (nbusybke). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - initbk initdtgl pfreeze - 15 14 13 12 11 10 9 8 - fifocon - nbusybke - ramacere - - 76543210 - rxstallde/ crcerre errorfie nakede perre txstpe txoute rxine
959 32117b?avr-03/11 at32uc3c this bit is set when the nbusybkes bit is written to one.this will enable the transmitted in data interrupt (nbusybke). ? ramacere: ram access error interrupt enable this bit is cleared when the nbusybkec bit is written to one. this will disable the transmitted in data interrupt (nbusybke). this bit is set when the nbusybkes bit is written to one.this will enable the transmitted in data interrupt (nbusybke). ? rxstallde: received st alled interrupt enable this bit is cleared when the rxstalldec bit is written to one. this will disable the transmitted in data interrupt (rxstallde). this bit is set when the rxstalldes bit is written to one. this will enable the transmitted in data interrupt (rxstallde). ? crcerre: crc error interrupt enable this bit is cleared when the crcerrec bit is written to one. this will disable the transmitted in data interrupt (crcerre). this bit is set when the crcerres bit is written to one. this will enable the transmitted in data interrupt (crcerre). ? errorfie: errorflow interrupt enable this bit is cleared when the errorfiec bit is written to one. this will disable the transmitted in data interrupt (overfie). this bit is set when the errorfies bit is written to one. this will enable the transmitted in data interrupt (overfie). ? nakede: naked interrupt enable this bit is cleared when the nakedec bit is written to one. this will disable the transmitted in data interrupt (nakede). this bit is set when the nakedes bit is written to one. this will enable the transmitted in data interrupt (nakede). ? perre: pipe error interrupt enable this bit is cleared when the perrec bit is written to one. this will disable the transmitted in data interrupt (perre). this bit is set when the perres bit is written to one. this will enable the transmitted in data interrupt (perre). ? txstpe: transmitted set up interrupt enable this bit is cleared when the txstpec bit is written to one. this will disable the transmitted in data interrupt (txstpe). this bit is set when the txstpes bit is written to one. this will enable the transmitted in data interrupt (txstpe). ? txoute: transmitted out data interrupt enable this bit is cleared when the txoutec bit is written to one. this will disable the transmitted in data interrupt (txoute). this bit is set when the txoutes bit is written to one. this will enable the transmitted in data interrupt (txoute). ? rxine: received in data interrupt enable this bit is cleared when the rxinec bit is written to one. this will disable the transmitted in data interrupt (rxine). this bit is set when the rxines bit is written to one. this will enable the transmitted in data interrupt (rxine).
960 32117b?avr-03/11 at32uc3c 32.7.3.15 pipe n control set register register name: upconnset, n in [0..6] access type: write-only offset: 0x05f0 + (n * 0x04) read value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in upconn. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - initbks initdtgls pfreezes - 15 14 13 12 11 10 9 8 --- nbusybkes ---- 76543210 - rxstalldes / crcerres errorfies nakedes perres txstpes txoutes rxines
961 32117b?avr-03/11 at32uc3c 32.7.3.16 pipe n control clear register register name: upconnclr, n in [0..6] access type: write-only offset: 0x0620 + (n * 0x04) read value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in upconn. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - initbkc initdtglc pfreezec - 15 14 13 12 11 10 9 8 - fifoconc - nbusybkec ---- 76543210 - rxstalldec / crcerrec errorfiec nakedec perrec txstpec txoutec rxinec
962 32117b?avr-03/11 at32uc3c 32.7.3.17 pipe n in request register register name: upinrqn, n in [0..6] access type: read/write offset: 0x0650 + (n * 0x04) reset value: 0x00000001 ? inmode: in request mode writing a zero to this bit will perform a pre-defined nu mber of in requests. this number is the inrq field. writing a one to this bit will allow the usbc to perform infinite in requests when the pipe is not frozen. ? inrq: in request number before freeze this field contains the number of in transactions before th e usbc freezes the pipe. the usbc will perform inrq in requests before freezing the pipe. this counter is automatically decreased by 1 each ti me an in request has been successfully performed. this register has no effect when the in mode bit is 0 (infinite in requests g eneration till the pipe is not frozen). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------inmode 76543210 inrq
963 32117b?avr-03/11 at32uc3c 32.8 module configuration the specific configuration for each usbc instance is listed in the following tables. the module bus clocks listed here are connected to the syst em bus clocks. please refer to the power man- ager chapter for details. table 32-11. module clock name module name clock name description usbc clk_usbc_hsb hsb clock clk_usbc_pb peripheral bus cl ock from the pbb clock domain gclk_usbc the generic clock used for the usbc is gclk0 table 32-12. register reset values register reset value uvers 0x00000210 ufeatures 7 uaddrsize 0x1000 uname1 0x48555342 uname2 0x004f5447
964 32117b?avr-03/11 at32uc3c 33. pulse width modulation controller (pwm) rev. 5.0.1.0 33.1 features ? 4 channels ? common clock generator providing thirteen different clocks ? a modulo n counter providing eleven clocks ? two independent linear dividers working on modulo n counter outputs ? high frequency asynchronous clocking mode ? independent channels ? independent 20-bit counter for each channel ? independent complementary outp uts with 16-bit dead-time gene rator (also called dead-band or non-overlapping time) for each channel ? independent enable disable command for each channel ? independent clock selection for each channel ? independent period, duty-cycle and dead-time for each channel ? independent double buffering of period, duty-cycle and dead-times for each channel ? independent programmable selection of the ou tput waveform polarity for each channel ? independent programmable center or left al igned output waveform for each channel ? independent output override for each channel ? 2 2-bit gray up/down channels for stepper motor control ? synchronous channel mode ? synchronous channels share the same counter ? mode to update the synchronous channels regi sters after a programmable number of periods ? synchronous channels supports connection wi th peripheral dma cont roller which offers buffer transfer without processor inte rvention to update duty-cycle values ? 2 independent events lines intended to synchonize adc conversions ? 8 comparison units intended to generate inte rrupts, pulses on event lines and pdc tranfer requests ? 5 programmable fault inputs providing an asynchronous protection of pwm outputs ? write-protect registers 33.2 overview the pwm controller (pwm) controls 4 channels independently. each channel controls two com- plementary square output waveforms. characteristics of the output waveforms such as period, duty-cycle, polarity and dead-times (also called dead-bands or non-overlapping times) are con- figured through the user interface. each channel selects and uses one of the clocks provided by the clock generator. the clock generator provides several clocks resulting from the division of the pwm internal clock (cck). this internal clock can be driven either by the master clock (clk_pwm) or by the generic clock (gclk). all pwm accesses are made through registers mapped on the peripheral bus. all channels inte- grate a double buffering system in order to prevent an unexpected output waveform while modifying the period, the duty-cycle or the dead-times. channels can be linked together as synchronous channels to be able to update their duty-cycle or dead-times at the same time. the update of duty-cycles of synchronous channels can be performed by the peripheral dma controller channel (pdca) which offers buffer transfer without processor intervention.
965 32117b?avr-03/11 at32uc3c the pwm provides 8 independent comparison units capable to compare a programmed value to the counter of the synchronous channels (counter of channel 0). these comparisons are intended to generate software interrupts, to trigger pulses on the 2 independent event lines (in order to synchronize adc conversions with a lot of flexibility independentl y of the pwm outputs), and to trigger pdca transfer requests. the pwm outputs can be overridden synchronously or asynchronously to their channel counter. the pwm controller provide a fault protection mechanism with 5 fault inputs , cap able to detect a fault condition and to override the pwm outputs asynchronously. for safety usage, some control registers are write-protected.
966 32117b?avr-03/11 at32uc3c 33.3 block diagram figure 33-1. pulse width modulation controller block diagram pwm channel x update period duty- cycle counter channel x comp arator mux clock selector pwmh[x] pwml[x] i/o controller pwmh[0] pwml[0] clock generator clk_pwm gclk ext_ faults[i] ext_ faults[i] comparison units event generator pevc event 0 event 1 user interface peripheral bus pdca channel 0 counter channel 0 channel y (=x+1) update period duty- cycle counter channel y dead-time generator output override fault protection mux syncy dtohy ooohy oooly clock selector comp arator 2-bit gray counter z z=0 (x=0, y=1) z=1 (x=2, y=3) z=2 (x=4, y=5) mux dtoly ocy dead-time generator output override fault protection dtohx ooohx ooolx mux dtolx ocx syncx pwmh[y] pwml[y]
967 32117b?avr-03/11 at32uc3c 33.4 i/o lines description each channel outputs two complementary external i/o lines. table 33-1. i/o line description name description type pwmhx pwm waveform output high for channel x output pwmlx pwm waveform output low for channel x output ext_faultsx pwm fault input x input
968 32117b?avr-03/11 at32uc3c 33.5 product dependencies 33.5.1 i/o lines the pins used for interfacing the pwm may be multiplexed with the i/o controller lines. the pro- grammer must first program the i/o controller to assign the desired pwm pins to their peripheral function. if i/o lines of the pwm are not used by the application, they can be used for other pur- poses by the i/o controller. 33.5.2 clocks the clock of the pwm (clk_pwm) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to disable the pwm before disabling the clock, to avoid freezing the pwm in an undefined state. the pwm counters can be fed by a generic clock (gclk). this is a high frequency clock which is asynchronous to clk_pwm. 33.5.3 interrupts the pwm interrupt line is connected to the interrupt controller. using the pwm interrupt requires the interrupt controller to be programmed first.
969 32117b?avr-03/11 at32uc3c 33.6 functional description the pwm controller is primarily composed of a clock generator module and 4 channels. ? the clock generator module provides 13 clocks . its source clock is ch osen according to the clksel bit in the clock register (clk). it allows to select: ? clk_pwm: the master clock (clock of the peripheral bus to which the pwm is connected) ? gclk: the generic clock (high frequency clock which is asynchronous to clk_pwm) ? each channel can independently choose one of the clock generator outputs. ? each channel generates an output waveform with attributes that can be defined independently for each channel through the user interface registers. 33.6.1 pwm clock generator figure 33-2. functional view of the clock generator block diagram modulo n counter cck clk_pwm gclk clksel divider a prea diva clka divider b preb divb clkb cck cck/2 cck/4 cck/32 cck/16 cck/8 cck/64 cck/128 cck/256 cck/512 cck/1024
970 32117b?avr-03/11 at32uc3c the pwm internal clock (named cck and driven either by clk_pwm or by gclk) is divided in the clock generator module to provide different clocks available for all channels. each channel can independently select one of the divided clocks. the selection of the source clo ck of the pwm counters is made by the clksel bit in the clk register. in asynchro nous clocking mode (clksel=1, gclk selected), th e pwm counters and the prescaler allow running the cpu from any clock source while the prescaler is operating on a faster clock (gclk). the clock generator is divided in three blocks: ? a modulo n counter which provides 11 clocks: f cck , f cck /2, f cck /4, f cck /8, f cck /16, f cck /32, f cck /64, f cck /128, f cck /256, f cck /512, f cck /1024 ? two linear dividers (1, 1/2, 1/3,... 1/255) that provide two separate clocks: clka and clkb each linear divider can independently divide one of the clocks of the modulo n counter. the selection of the clock to be divided is made ac cording to the prea (preb) field of the pwm clock register (pwm_clk). the resulting clock clka (clkb) is the clock selected divided by diva (divb) field value. after a reset of the pwm controller, diva (divb) and prea (preb) are set to 0. this implies that after reset clka (clkb) are turned off. at reset, all clocks provided by the modulo n counter are turned off except clock ?cck?. this sit- uation is also true when the pwm master clock is turned off through the power management controller. caution : ? before using the pwm, the programmer must first enable the pwm clock in the power manager (pm). ? the master clock frequency (clk_pwm) must be lower than half of the generic clock frequency (gclk) due to the synchronization mechanism between both clock domains. ? after selecting a new pwm input clock (writt en clksel to a new value), no write in any pwm registers must be attempted before a delay of 2 master clock periods (clk_pwm). this is the time needed by the pwm to switch the source of the internal clock (cck).
971 32117b?avr-03/11 at32uc3c 33.6.2 pwm channel 33.6.2.1 block diagram figure 33-3. functional view of the channel block diagram each of the 4 channels is composed of six blocks: ? a clock selector which selects one of the clocks provided by the clock generator (described in section 33.6.1 on page 969 ). ? a counter clocked by the output of the clock selector. this counter is incremented or decremented according to the channel configuration and comparators matches. the size of the counter is 20 bits. ? a comparator used to compute the ocx output waveform according to the counter value and the configuration. the counter value can be the one of the channel counter or the one of the channel 0 counter according to syncx bit in the ?sync channels mode register? on page 1007 (scm). ? a 2-bit configurable gray counter enables the stepper motor driver. one gray counter drives 2 channels. ? a dead-time generator providing two complementary outputs (dtohx/dtolx) which allows to drive external power control switches safely. ? an output override block that can force the two complementary outputs to a programmed value (ooohx/ooolx). ? an asynchronous fault protection mechanism that has the highest priority to override the two complementary outputs in case of fault detection (pwmhx/pwmlx). counter channel 0 channel x update period duty- cycle counter channel x comp arator mux clock selector pwmhx pwmlx dead-time generator output override fault protection dtohx ooohx ooolx mux dtolx ocx syncx 2-bit gray counter z z=0 (x=0, y=1) z=1 (x=2, y=3) z=2 (x=4, y=5)
972 32117b?avr-03/11 at32uc3c 33.6.2.2 comparator the comparator continuously compares its counter value with the channel period defined by cprd in the ?channel period register? on page 1041 (cprdx) and the duty-cycle defined by cdty in the ?channel duty cycle register? on page 1039 (cdtyx) to generate an output signal ocx accordingly. the different properties of the waveform of the output ocx are: ? the clock selection . the channel counter is clocked by one of the clocks provided by the clock generator described in the previous section. this channel parameter is defined in the cpre field of the ?channel mode register? on page 1037 (cmrx). this field is reset at 0. ? the waveform period . this channel parameter is defined in the cprd field of the cprdx register. - if the waveform is left aligned, then the output waveform period depends on the counter source clock and can be calculated: by using the pwm internal clock (cck) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024), the resulting period formula will be: by using the pwm internal clock (cck) divided by one of both diva or divb divider, the formula becomes, respectively: or if the waveform is center aligned then the output waveform period depends on the counter source clock and can be calculated: by using the pwm internal clock (cck) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024 ). the resulting period formula will be: by using the pwm internal clock (cck) divided by one of both diva or divb divider, the formula becomes, respectively: or ? the waveform duty-cycle . this channel parameter is defined in the cdty field of the cdtyx register. if the waveform is left aligned then: if the waveform is center aligned, then: xcprd () cck ------------------------------- crpd diva () cck ------------------------------------------ crpd divb () cck ------------------------------------------ 2 x cprd () cck ---------------------------------------- - 2 cprd diva () cck --------------------------------------------------- - 2 cprd divb () cck --------------------------------------------------- - duty cycle period 1 fchannel_x_clock cdty ? ? () period ------------------------------------------------------------------------------------------------------- - = duty cycle period 2 ? () 1 fchannel_x_clock cdty ? ? ()) period 2 ? () ---------------------------------------------------------------------------------------------------------------------- - =
973 32117b?avr-03/11 at32uc3c ? the waveform polarity. at the beginning of the period, the signal can be at high or low level. this property is defined in the cpol field of the cmrx register. by default the signal starts by a low level. ? the waveform alignment . the output waveform can be left or center aligned. center aligned waveforms can be used to generate non overlapped waveforms. this property is defined in the calg field of the cmrx register. the default mode is left aligned. figure 33-4. non overlapped center aligned waveforms note: 1. see figure 33-5 on page 974 for a detailed description of center aligned waveforms. when center aligned, the channel counter increases up to cprd and decreases down to 0. this ends the period. when left aligned, the channel counter increases up to cprd and is reset. this ends the period. thus, for the same cprd value, the period for a ce nter aligned channel is twice the period for a left aligned channel. waveforms are fixed at 0 when: ? cdty = cprd and cpol = 0 ? cdty = 0 and cpol = 1 waveforms are fixed at 1 (once the channel is enabled) when: ? cdty = 0 and cpol = 0 ? cdty = cprd and cpol = 1 the waveform polarity must be written before enabling the channel. this immediately affects the channel output level. changes on channel polari ty are not taken into account while the channel is enabled. besides generating output signals ocx, the comparator generates interrupts in function of the counter value. when the output waveform is left aligned, the interrupt occurs at the end of the counter period. when the output waveform is center aligned, the ces bit of the cmrx register defines when the channel counter interrupt occurs. if ces is set to 0, the interrupt occurs at the end of the counter period. if ces is set to 1, th e interrupt occurs at the end of the counter period and at half of the counter period. figure 33-5 on page 974 illustrates the counter interrupts in function of the configuration. oc0 oc1 period no overlap
974 32117b?avr-03/11 at32uc3c figure 33-5. waveform properties channel x slected clock chidx(pwm_sr) center aligned cprd(pwm_cprdx) cdty(pwm_cdtyx) pwm_ccntx output waveform ocx cpol(pwm_cmrx) = 0 output waveform ocx cpol(pwm_cmrx) = 1 counter event chidx(pwm_isr) ces(pwm_cmrx) = 0 left aligned cprd(pwm_cprdx) cdty(pwm_cdtyx) pwm_ccntx output waveform ocx cpol(pwm_cmrx) = 0 output waveform ocx cpol(pwm_cmrx) = 1 calg(pwm_cmrx) = 0 calg(pwm_cmrx) = 1 period period chidx(pwm_ena) chidx(pwm_dis) counter event chidx(pwm_isr) ces(pwm_cmrx) = 1 counter event chidx(pwm_isr)
975 32117b?avr-03/11 at32uc3c 33.6.2.3 2-bit gray up/down counter for stepper motor it is possible to configure a couple of channels to provide a 2-bit gray count waveform on 2 out- puts. dead-time generator and other downstream logic can be configured on these channels. up or down count mode can be configured on-the-fly by the smmr register. when gcen0 is written to 1, channels 0 and 1 outputs are driven with gray counter. figure 33-6. 2-bit gray up/down counter 33.6.2.4 dead-time generator the dead-time generator uses the comparator output ocx to provide the two complementary outputs dtohx and dtolx, which allows the pw m to drive external power control switches safely. when the dead-time generator is enabled by writing a one to the dte bit in the ?channel mode register? on page 1037 (cmrx), dead-times (also called dead-bands or non-overlapping times) are inserted between the edges of the two complementary outputs dtohx and dtolx. note that enabling or disabling the dead-time generator is allowed only if the channel is disabled. the dead-time is adjustable by the ?channel dead time register? on page 1046 (dtx), both outputs of the dead-time generator can be adjusted separately by dth and dtl. the dead-time values can be updated synchronously to the pwm period by using the ?channel dead time update register? on page 1047 (dtupdx). the dead-time is based on a specific counter whic h uses the same selected clock that feeds the channel counter of the comparator. depending on the edge and the configuration of the dead- time, dtohx and dtolx are delayed until the counter has reached the value defined by dth or dtl. an inverted configuration bit (dthi and dtli bits in the cmrx register) is provided for each outputs to invert the dead-times outputs. the following figure shows the waveform of the dead- time generator. pwmh0 downx gcen0 = 1 pwmh1 pwml0 pwml1
976 32117b?avr-03/11 at32uc3c figure 33-7. complementary output waveforms dthx dtlx output waveform ocx cpolx = 0 output waveform dtohx dthix = 0 output waveform dtolx dtlix = 0 output waveform dtohx dthix = 1 output waveform dtolx dtlix = 1 dthx dtlx output waveform ocx cpolx = 1 output waveform dtohx dthix = 0 output waveform dtolx dtlix = 0 output waveform dtohx dthix = 1 output waveform dtolx dtlix = 1
977 32117b?avr-03/11 at32uc3c 33.6.2.5 output override the two complementary outputs dtohx and dtolx of the dead-time generator can be forced to a value defined by the software. figure 33-8. override output selection the oshx and oslx fields in the ?output selection register? on page 1017 (os) allow the out- puts of the dead-time generator dtohx and dtolx to be overridden by the value defined in the oovhx and oovlx fields in the ?output override value register? on page 1016 (oov). the set registers ?output selection set register? on page 1018 and ?output selection set update register? on page 1020 (oss and ossupd) enable the override of the outputs of a channel regardless of other channels. in the same way, the clear registers ?output selection clear register? on page 1019 and ?output selection clear update register? on page 1021 (osc and oscupd) disable the override of the outputs of a channel regardless of other channels. by using buffer ossupd and oscupd registers, the output selection of pwm outputs is done synchronously to the channel counter, at the beginning of the next pwm period. by using oss and osc registers, the output selection of pwm outputs is done asynchronously to the channel counter, as soon as the register is written. the value of the current output selection can be read in os. while overriding pwm outputs, the channel counters continue to run, only the pwm outputs are forced to user defined values. dtohx oovhx ooohx oshx 0 1 dtolx oovlx ooolx oslx 0 1
978 32117b?avr-03/11 at32uc3c 33.6.2.6 fault protection 5 inputs provide fault protection which can force any of the pwm output pair to a programmable value. this mechanism has priority over output overriding. figure 33-9. fault protection the polarity level of the faults inputs are configured by the fpol field in the ?fault mode regis- ter? on page 1022 (fmr). the fault inputs can be glitch filtered or not in function of the ffil field in the fmr register. when the filter is enabled, glitches on fault inputs with a width inferior to the pwm internal clock (cck) period are rejected. a fault becomes active as soon as its corres ponding fault input has a transition to the pro- grammed polarity level. if the corresponding fmod bit is written to zero in the fmr register, the fault remains active as long as the fault input is at this polarity level. if the corresponding bit fmod is written to one, the fault remains active until the fault input is not at this polarity level anymore and until it is cleared by writing the corresponding fclr bit in the ?fault clear regis- ter? on page 1024 (fscr). by reading the ?fault status resister? on page 1023 (fsr), the user can read the current level of the fault inputs thanks to the fiv field, and can know which fault is currently active thanks to the fs field. each fault can be taken into account or not by the fault protection mechanism in each channel. to be taken into account in the channel x, the fault y must be enabled by the fpex[y] bit in the ?pwm fault protection enable registers? (fpe1). however the synchronous channels (see section 33.6.2.7 on page 980 ) don?t use their own fault enable bits, but those of the channel 0 (fpe0[y] bits). the fault protection on a channel is triggere d when this channel is enabled and when any one of the faults that are enabled for this channel is active. it can be triggered even if the pwm inter- nal clock (cck) is not running but only by a fault input that is not glitch filtered. when the fault protection is triggered on a channel, the fault pr otection mechanism forces the channel outputs to the values defined by the fpvhx and fpvlx fields in the ?fault protection value register? on page 1025 (fpv) and leads to a reset of the counter of this channel. the out- put forcing is made asynchronously to the channel counter. caution: fiv0 fault input 0 fault protection on pwm channel x glitch filter ffil0 from fault 0 from fault y 1 0 = fpol0 fmod0 1 0 fault 0 status fs0 fiv1 glitch filter ffil1 1 0 = fpol1 set clr fmod1 1 0 out fault 1 status fs1 fault input 1 from fault 1 1 0 0 1 from output override oohx oolx from output override fpvhx fpvlx pwmhx pwmlx fault input y fmod1 set clr write fclr0 at 1 out fmod0 write fclr1 at 1 syncx 1 0 fpex[0] fpe0[0] syncx 1 0 fpex[1] fpe0[1]
979 32117b?avr-03/11 at32uc3c ? to prevent an unexpected activation of the status fsy bit in the fsr register, the fmody bit can be written to one only if the fpoly bit has been previously configur ed to its final value. ? to prevent an unexpected activation of the faul t protection on the channel x, the fpex[y] bit can be written to one only if the fpoly bit has been previously configur ed to its final value. if a comparison unit is enabled (see section 33.6.3 on page 988 ) and if a fault is triggered in the channel 0, in this case the comparison cannot match. as soon as the fault protection is triggered on a channel, an interrupt (different from the interrupt generated at the end of the pwm period) can be generated but only if it is enabled and not masked. the interrupt is reset by reading the interrupt status register, even if the fault which has caused the trigger of the fault protection is kept active.
980 32117b?avr-03/11 at32uc3c 33.6.2.7 synchronous channels some channels can be linked together as synchronous channels. they have the same source clock, the same period, the same alignment and are started together. in this way, their counters are synchronized together. the synchronous channels are defined by the syncx bits in the ?sync channels mode regis- ter? on page 1007 (scm). only one group of sy nchronous channels is allowed. when a channel is defined as a synchronous c hannel, the channel 0 is automatically defined as a synchronous channel too, because the channel 0 counter configuration is used by all the syn- chronous channels. if a channel x is defined as a synchronous channel, it uses the following configuration fields of the channel 0 instead of its own: ? cpre0 field in cmr0 register instead of cprex field in cmrx register (same source clock) ? cprd0 field in cmr0 register instead of cprdx field in cmrx register (same period) ? calg0 field in cmr0 register instead of calgx field in cmrx register (same alignment) thus writing these fields of a synchronous channel has no effect on the output waveform of this channel (except channel 0 of course). because counters of synchronous channels must start at the same time, they are all enabled together by enabling the channel 0 (by the chid0 bit in the ena register). in the same way, they are all disabled together by disabling the channel 0 (by the chid0 bit in the dis register). how- ever, a synchronous channel x different fr om channel 0 can be enabled or disabled independently from others (by the chidx bit in the ena and dis registers). defining a channel as a synchronous channel while it is an asynchronous channel (by writing the syncx bit to one while it was at zero) is allo wed only if the channel is disabled at this time (chidx=0 in sr register) . in the same way, defining a channel as an asynchronous channel while it is a synchronous channel (by writing the syncx bit to zero while it was at one) is allowed only if the channel is disabled at this time. the updm (update mode) field in the scm register allow to select one of the three methods to update the registers of the synchronous channels: ? method 1 (updm=0): the period value, the duty-cycle values and the dead-time values must be written by the cpu in their respective update registers (respectively cprdupdx, cdtyupdx and dtupdx).the update is triggered at the next pwm period as soon as the updulock bit in the ?sync channels update control register? on page 1009 (scuc) is set to 1 (see section 33.6.2.8 on page 982 ). ? method 2 (updm=1): the period value, the duty-cycle values, the dead-time values and the update period value must be written by the cpu in their respective update registers (respectively cprdupdx, cdtyupdx and dtupd). the update of the period value and of the dead-time values is triggered at the next pwm period as soon as the updulock bit in the ?sync channels update control register? on page 1009 (scuc) is set to 1. the update of the duty-cycle values and the update period value is triggered automatically after an update period defined by the upr field in the ?sync channels update period register? on page 1010 (scup) (see section 33.6.2.9 on page 983 ). ? method 3 (updm=2): same as method 2 apart from the fact that the duty-cycle values of all synchronous channels are written by the peripheral dma controller (pdca) (see section
981 32117b?avr-03/11 at32uc3c 33.6.2.10 on page 985 ). the user can choose to synchronize the pdca transfer request with a comparison match (see section 33.6.3 on page 988 ), by the ptrm and ptrcs fields in the scm register. table 33-2. summary of the update of registers of synchronous channels updm=0 updm=1 updm=2 period value ( cprdupdx) write by the cpu update is triggered at the next pwm period as soon as the updulock bit is set to 1 dead-time values ( dtupdx) write by the cpu update is triggered at the next pwm period as soon as the updulock bit is set to 1 duty-cycle values ( cdtyupdx) write by the cpu write by the cpu write by the pdca update is triggered at the next pwm period as soon as the updulock bit is set to 1 update is triggered at the next pwm period as soon as the update period counter has reached the value upr update period value ( scupupd) not applicable write by the cpu not applicable update is triggered at the next pwm period as soon as the update period counter has reached the value upr
982 32117b?avr-03/11 at32uc3c 33.6.2.8 method 1: manual write of duty-cycle values and manual trigger of the update in this mode, the update of the period value, the duty-cycle values and the dead-time values must be made by writing in their respective update registers with the cpu (respectively cpr- dupdx, cdtyupdx and dtupdx). to trigger the update, the user must use the updulock bit of the ?sync channels update con- trol register? on page 1009 (scuc) which allows to update synchronously (at the same pwm period) the synchronous channels: ? if the updulock bit is set to 1, the update is done at the next pwm period of the synchronous channels. ? if the updulock bit is not set to 1, the update is locked and cannot be performed. after writing the updulock bit to 1, it is held at this value until the update occurs, then it is read 0. sequence for the method 1: 1. select the manual write of duty-cycle values and the manual update by writing the updm field to zero in the scm register 2. define the synchronous channels by the syncx bits in the scm register. 3. enable the synchronous channels by writing chid0 in the ena register. 4. if an update of the period value and/or the duty-cycle values and/or the dead-time val- ues is required, write registers that need to be updated (cprdupdx, cdtyupdx and dtupdx). 5. write updulock to one in scuc. 6. the update of th e registers will occur at the beginning of the next pwm period. at this time the updulock bit is reset, go to step 4) for new values. figure 33-10. method 1 (updm=0) ccnt0 cdtyupd 0x20 0x40 0x60 updulock cdty 0x20 0x40 0x60
983 32117b?avr-03/11 at32uc3c 33.6.2.9 method 2: manual write of duty-cycle values and automatic trigger of the update in this mode, the update of the period value, the duty-cycle values, the dead-time values and the update period value must be made by writing in their respective update registers with the cpu (respectively cprdupdx, cdtyupdx, dtupdx and scupupd). to trigger the update of the period value and the dead-time values, the user must use the updulock bit of the ?sync channels update control register? on page 1009 (scuc) which allows to update synchronously (at the same pwm period) the synchronous channels: ? if the updulock bit is set to 1, the update is done at the next pwm period of the synchronous channels. ? if the updulock bit is not set to 1, the update is locked and cannot be performed. after writing the updulock bit to one, it is held at this value until the update occurs, then it is read 0. the update of the duty-cycle values and the up date period is triggered automatically after an update period. to configure the automatic update, the user must define a value for the update period by the upr field in the ?sync channels update period register? on page 1010 (scup). the pwm con- troller waits upr+1 periods of synchronous channels before updating automatically the duty values and the update period value. the status of the duty-cycle value write is reported in the ?interrupt status register 2? on page 1015 (isr2) by the following bits: ? wrdy: this bit is set to 1 when the pwm contro ller is ready to receive new duty-cycle values and a new update period value. it is reset to 0 when the isr2 register is read. depending on the interrupt mask in the imr2 register, an interrupt can be generated by these bits. sequence for the method 2: 1. select the manual write of duty-cycle values and the automatic update by writing the updm field to one in the scm register 2. define the synchronous channels by the syncx bits in the scm register. 3. define the update period by the upr field in the scup register. 4. enable the synchronous channels by writing chid0 in the ena register. 5. if an update of the period value and/or of the dead-time values is required, write regis- ters that need to be updated (cprdupdx, dtupdx), else go to step 8. 6. write updulock to one in scuc. 7. the update of th ese registers will occur at the beginning of the next pwm period. at this moment the updulock bit is reset, go to step 5. for new values. 8. if an update of the duty-cycle values and/or the update period is required, check first that write of new update values is possible by polling the wrdy bit (or by waiting for the corresponding interrupt) in the isr2 register. 9. write registers that need to be updated (cdtyupdx, scupupd). 10. the update of thes e registers will occur at the next pwm period of the synchronous channels when the update period is elapsed. go to step 8. for new values.
984 32117b?avr-03/11 at32uc3c figure 33-11. method 2 (updm=1) ccnt0 cdtyupd 0x20 0x40 0x60 uprcnt 0x0 0x1 0x0 0x1 0x0 0x1 cdty 0x20 0x40 uprupd 0x1 0x3 wrdy 0x60 0x0 0x1 0x2 0x3 0x0 0x1 0x2 upr 0x1 0x3
985 32117b?avr-03/11 at32uc3c 33.6.2.10 method 3: automatic write of duty-cycle values and automatic trigger of the update in this mode, the update of the duty cycle values is made automatically by the peripheral dma controller (pdca). the update of the period value, the dead-time values and the update period value must be made by writing in their respective update registers with the cpu (respectively cprdupdx, dtupdx and scupupd). to trigger the update of the period value and the dead-time values, the user must use the updulock bit which allows to update synchronously (at the same pwm period) the synchro- nous channels: ? if the updulock bit is set to 1, the update is done at the next pwm period of the synchronous channels. ? if the updulock bit is not set to 1, the update is locked and cannot be performed. after writing the updulock bit to one, it is held at this value until the update occurs, then it is read 0. the update of the duty-cycle values and the update period value is triggered automatically after an update period. to configure the automatic update, the user must define a value for the update period by the upr field in the ?sync channels update period register? on page 1010 (scup). the pwm con- troller waits upr+1 periods of synchronous channels before updating automatically the duty values and the update period value. using the pdca removes processor overhead by reducing its intervention during the transfer. this significantly reduces the number of clock cycles required for a data transfer, which improves micro controller performance. the pdca must write the duty-cycle values in the synchronous channels index order. for exam- ple if the channels 0, 1 and 3 are synchronous channels, the pdca must write the duty-cycle of the channel 0 first, then the duty-cycle of the ch annel 1, and finally the duty-cycle of the channel 3. the following status are reported in the ?interrupt status register 2? on page 1015 (isr2): ? wrdy: this bit is set to 1 when the pwm contro ller is ready to receive new duty-cycle values and a new update period value. it is reset to 0 when the isr2 register is read. the user can choose to synchronize the wrdy bit and the pdca transfer request with a comparison match (see section 33.6.3 on page 988 ), by the ptrm and ptrcs fields in the scm register. ? unre: this bit is set to 1 when the update period defined by the upr field is elapsed while the whole data has not been written by the pdca. it is reset to 0 when the isr2 register is read. depending on the interrupt mask in the imr2 register, an interrupt can be generated by these bits.
986 32117b?avr-03/11 at32uc3c sequence for method 3: 1. select the automatic write of duty-cycle va lues and automatically update by setting the updm field to 2 in the scm register. 2. define the synchronous channels by the syncx bits in the scm register. 3. define the update period by the upr field in the scup register. 4. define when the wrdy bit and the corresponding pdca transfer request must be set in the update period by the ptrm bit and the ptrcs field in the scm register (at the end of the update period or when a comparison matches). 5. define the pdca transfer settings for the duty-cycle values and enable it in the pdca registers 6. enable the synchronous channels by writing chid0 in the ena register. 7. if an update of the period value and/or of the dead-time values is required, write regis- ters that need to be updated (cprdupdx, dtupdx), else go to step 10. 8. write updulock to one in scuc. 9. the update of th ese registers will occur at the beginning of the next pwm period. at this moment the updulock bit is reset, go to step 7. for new values. 10. if an update of the update period value is required, check first that write of a new update value is possible by polling the wrdy bit (or by waiting for the corr esponding interrupt) in the isr2 register, else go to step 13. 11. write register that need to be updated (scupupd). 12. the update of this registers will occur at the next pwm period of the synchronous chan- nels when the update period is elapsed. go to step 10. for new values. 13. check the end of the pdca transfer with the transfer complete bit in the pdca status register. if the transfer is ended define a new pdca transfer in the pdca registers, for new duty-cycle values. go to step 5.
987 32117b?avr-03/11 at32uc3c figure 33-12. method 3 (updm=2 and ptrm=0) figure 33-13. method 3 (updm=2 and ptrm=1 and ptrcs=0) ccnt0 cdtyupd 0x20 0x40 0x60 uprcnt 0x0 0x1 0x0 0x1 0x0 0x1 cdty uprupd 0x1 0x3 pdc transfer request wrdy 0x0 0x1 0x2 0x3 0x0 0x1 0x2 upr 0x1 0x3 0x80 0xa0 0xb0 0x20 0x40 0x60 0x80 0xa0 ccnt0 cdtyupd 0x20 0x40 0x60 uprcnt 0x0 0x1 0x0 0x1 0x0 0x1 cdty uprupd 0x1 0x3 cmp0 match pdc transfer request wrdy 0x0 0x1 0x2 0x3 0x0 0x1 0x2 upr 0x1 0x3 0x80 0xa0 0xb0 0x20 0x40 0x60 0x80 0xa0
988 32117b?avr-03/11 at32uc3c 33.6.3 pwm comparison units the pwm provides 8 independent comparison units able to compare a programmed value with the current value of the channel 0 counter (which is the channel counter of all synchronous channels, section 33.6.2.7 on page 980 ). these comparisons are intended to generate pulses on the event lines (used to synchronize adc, see section 33.6.4 on page 990 ), to generate soft- ware interrupts and to trigger pdca transfer requests for the synchronous channels (see section 33.6.2.10 on page 985 ). figure 33-14. comparison unit block diagram the comparison x matches when it is enabled by the cen bit in the ?comparison x mode regis- ter? on page 1035 (cmpxm for the comparison x) and when the counter of the channel 0 reaches the comparison value defined by the cv field in ?comparison x value register? on page 1033 (cmpxv for the comparison x). if the counter of the channel 0 is center aligned (calg=1 in ?channel mode register? on page 1037 ), the cvm bit (in cmpxv) defines if the comparison is made when the counter is counting up or counting down (in left alignment mode calg=0, this bit is useless). if a fault is active on the channel 0, the comparison is disabled and cannot match (see section 33.6.2.6 on page 978 ). the user can define the periodicity of the comp arison x by the ctr and cpr fields (in cmpxv). the comparison is performed periodically once every cpr+1 periods of the counter of the chan- nel 0, when the value of the comparison period counter cprcnt (in cmpxm) reaches the value defined by ctr. cpr is the maximum value of the compar ison period counter cprcnt. if cpr=ctr=0, the comparison is performed at each period of the counter of the channel 0. the comparison x configuration can be modifi ed while the channel 0 is enabled by using the ?pwm comparison x mode update register? on page 1036 (cmpxmupd registers for the com- parison x). in the same way, the comparison x value can be modified while the channel 0 is enabled by using the ?comparison x value update register? on page 1034 (cmpxvupd regis- ters for the comparison x). = fault on channel 0 cnt [pwm_ccnt0] cnt [pwm_ccnt0] is decrementing calg [pwm_cmr0] cv [pwm_cmpxv] = 1 0 1 comparison x cvm [pwm_cmpxv] = cprcnt [pwm_cmpxm] ctr [pwm_cmpxm] cen [pwm_cmpxm]
989 32117b?avr-03/11 at32uc3c the update of the comparison x configuration and the comparison x value is triggered periodi- cally after the comparison x update period. it is defined by the cupr field in the cmpxm. the comparison unit has an update period counter independent from the period counter to trigger this update. when the value of the comparison update period counter cuprcnt (in cmpxm) reaches the value defined by cupr, the update is triggered. the comparison x update period cupr itself can be updated while the channel 0 is enabled by using the cmpxmupd register. caution: to be taken into account, writing in the cmpxvupd register must be followed by a write in the cmpxmupd register. the comparison match and the comparison update can be a source of an interrupt, but only if it is enabled and not masked. these interrupts can be enabled by the ?interrupt enable register 2? on page 1012 and disabled by the ?interrupt disable register 2? on page 1013 . the compari- son match interrupt and the comparison update interrupt are reset by reading the ?interrupt status register 2? on page 1015 . figure 33-15. comparison waveform ccnt0 cvupd 0x6 0x2 cvmvupd cv 0x6 0x2 0x6 0x6 cvm comparison update cmpu ctrupd 0x1 0x2 cpr 0x1 0x3 0x0 0x1 0x0 0x1 0x0 0x1 0x2 0x3 0x0 0x1 0x2 0x3 cprcnt 0x0 0x1 0x2 0x3 0x0 0x1 0x2 0x0 0x1 0x2 0x0 0x1 cuprcnt cprupd 0x1 0x3 cuprupd 0x3 0x2 ctr 0x1 0x2 cupr 0x3 0x2 comparison match cmpm
990 32117b?avr-03/11 at32uc3c 33.6.4 pwm event lines the pwm provides 2 independent event lines intended to trigger actions in other peripherals (in particular for adc (analo g to digital converter)). a pulse (one cycle of the master clock (clk_pwm)) is generated on an event line, when at least one of the selected comparisons is matching. the comparisons can be selected independently by the csel bits in the ?event line x register? on page 1027 (elxmr for the event line x). figure 33-16. event line block diagram pulse generator event line x csel0 (pwm_elxmr) cmps0 (pwm_isr2) csel1 (pwm_elxmr) cmps1 (pwm_isr2) csel2 (pwm_elxmr) cmps2 (pwm_isr2) csel7 (pwm_elxmr) cmps7 (pwm_isr2)
991 32117b?avr-03/11 at32uc3c 33.6.5 pwm controller operations 33.6.5.1 initialization before enabling the channels, they must have been configured by the software application: ? unlock user interface by writing the wpcmd field in the wpcr register. ? configuration of the clock generator (diva, prea, divb, preb, clksel in the clk register if required). after writing clksel to a new value, no write in any pwm registers must be attempted before a delay of 2 master clock periods (clk_pwm). this is the time needed by the pwm to switch the internal clock (cck). ? selection of the clock for each channel (cpre field in the cmrx register) ? configuration of the waveform alignment for each channel (calg field in the cmrx register) ? selection of the counter event selection (if calg=1) for each channel (ces field in the cmrx register) ? configuration of the output waveform polarity for each channel (cpol in the cmrx register) ? configuration of the period for each channel (cprd in the cprdx register). writing in cprdx register is possible while the channel is disabled. after validation of the channel, the user must use cprdupdx register to update cprdx as explained below. ? configuration of the duty-cycle for each channel (cdty in the cdtyx register). writing in cdtyx register is possible while the channel is disabled. after validation of the channel, the user must use cdtyupdx register to update cdtyx as explained below. ? configuration of the dead-time generator for each channel (dth and dtl in dtx) if enabled (dte bit in the cmrx register). writing in the dtx register is possible while the channel is disabled. after validation of the channel, the user must use dtupdx register to update dtx ? selection of the synchronous channels (syncx in the scm register) ? selection of the moment when the wrdy bit and the corresponding pdca transfer request are set (ptrm and ptrcs in the scm register) ? configuration of the update mode (updm in the scm register) ? configuration of the update period (upr in the scup register) if needed. ? configuration of the comparisons (cmpxv and cmpxm). ? configuration of the event lines (elxmr). ? configuration of the fault inputs polarity (fpol in fmr) ? configuration of the fault protection (fmod and ffil in fmr, fpv and fpe1) ? enable of the interrupts (writing chidx and fchidx in ier1 regist er, and writing wrdye, unre, cmpmx and cmpux in ier2 register) ? enable of the channels (writing chidx in the ena register)
992 32117b?avr-03/11 at32uc3c 33.6.5.2 source clock selection criteria the large number of source clocks can make selection difficult. the relationship between the value in the ?channel period register? on page 1041 (cprdx) and the ?channel duty cycle register? on page 1039 (cdtyx) can help the user. the event number written in the period reg- ister gives the pwm accuracy. the duty-cycle quantum cannot be lower than 1/cprdx value. the higher the value of cprdx, the greater the pwm accuracy. for example, if the user writes 15 (in decimal) in cprdx, the user is able to write a value between 1 up to 14 in cdtyx register. the resulting duty-cycle quantum cannot be lower than 1/15 of the pwm period. 33.6.5.3 changing the duty-cycle, the period and the dead-times it is possible to modulate the output waveform duty-cycle, period and dead-times. to prevent unexpected output waveform, the user must use the ?channel duty cycle update register? on page 1040 , the ?channel period update register? on page 1043 and the ?channel dead time update register? on page 1047 (cdtyupdx, cprdupdx and dtupdx) to change waveform parameters while th e channel is still enabled. ? if the channel is an asynchronous channel (syncx=0 in ?sync channels mode register? on page 1007 (scm)), these registers hold the new period, duty-cycle and dead-times values until the end of the current pwm period and update the values for the next period. ? if the channel is a synchronous channel and update method 0 is selected (syncx=1 and updm=0 in scm register), these registers hold the new period, duty-cycle and dead-times values until the updulock bit is written to one (in ?sync channels updat e control register? on page 1009 (scuc)) and the end of the current pwm period, then update the values for the next period. ? if the channel is a synchronous channel and update method 1 or 2 is selected (syncx=1 and updm=1 or 2 in scm register): ? these cprdupdx and dtupdx registers hold the new period and dead-times values until the updulock bit is written to one (in scuc register) and the end of the current pwm period, then update the values for the next period. ? the cdtyupdx register holds the new duty-cycle value until the end of the update period of synchronous channels (when uprcnt is equal to upr in ?sync channels update period register? on page 1010 (scup)) and the end of the current pwm period, then updates the value for the next period note: if the update registers (cdtyupdx, cprdupdx and dtupdx) are written several times between two updates, only the last written value is taken into account. 33.6.5.4 changing the synchronous channels update period it is possible to change the update period of synchronous channels (see section 33.6.2.9 on page 983 and section 33.6.2.10 on page 985 ) while they are enabled. to prevent an unexpected update of the synchronous channels registers, the user must use the ?sync channels update period update register? on page 1011 (scupupd) to change the update period of synchronous ch annels while they are still enabled . this register holds the new value until the end of the update period of synchronous channels (when uprcnt is equal to
993 32117b?avr-03/11 at32uc3c upr in ?sync channels update period register? on page 1010 (scup)) and the end of the cur- rent pwm period, then updates the value for the next period. note: if the scupupd update register is written seve ral times between two updates, only the last writ- ten value is taken into account. note: changing the update period does make sense only if there is one or more synchronous channels and if the update method 1 or 2 is selected (updm=1 or 2 in ?sync channels mode register? on page 1007 ). 33.6.5.5 changing the comparison value and the comparison configuration it is possible to change the comparison values and the comparison configurations while the channel 0 is enabled (see section 33.6.3 on page 988 ). to prevent unexpected comparison match, the user must use the ?comparison x value update register? on page 1034 and the ?pwm comparison x mode update register? on page 1036 (cmpxvupd and cmpxmupd) to change respectively the comparison values and the compari- son configurations while the cha nnel 0 is still enabled. these registers hold the new values until the end of the comparison update period (when cuprcnt is equal to cupr in ?comparison x mode register? on page 1035 (cmpxm)) and the end of the current pwm period, then update the values for the next period. caution: to be taken into account, the write of the cmpxvupd register must be followed by a write of the cmpxmupd register. note: if the update registers cmpxvupd and cmpxmupd are written several times between two updates, only the last written value are taken into account. 33.6.5.6 interrupts depending on the interrupt mask in the imr1 and imr2 registers, an interrupt can be generated at the end of the corresponding channel period (chidx in the isr1 register), after a fault event (fchidx in the isr1 register), after a comparison match (cmpmx in the isr2 register), after a comparison update (cmpux in the isr2 register) or according to the transfer mode of the syn- chronous channels (wrdy and unre in the isr2 register). if the interrupt is generated by the chidx or fc hidx bits, the interrupt remains active until a read operation in the isr1 register occurs. if the interrupt is ge nerated by the wrdy, unre, cmpmx or cmpux bits, the interrupt remains active until a read operation in the isr2 register occurs. a channel interrupt is enabled by setting the corresponding bit in the ier1 and ier2 registers. a channel interrupt is disabled by setting the co rresponding bit in the idr1 and idr2 registers.
994 32117b?avr-03/11 at32uc3c 33.6.5.7 write protect registers to prevent any single software error that may corrupt pwm behavior, the registers listed below can be write-protected by writing the wpcmd field in the ?write protect control register? on page 1029 (wpcr). they are divided into 6 groups: ? register group 0: ? ?clock register? on page 998 ? register group 1: ? ?disable register? on page 1001 ? register group 2: ? ?sync channels mode register? on page 1007 ? ?channel mode register? on page 1037 ? ?stepper motor mode register? on page 1028 ? register group 3: ? ?channel period register? on page 1041 ? ?channel period update register? on page 1043 ? register group 4: ? ?channel dead time register? on page 1046 ? ?channel dead time update register? on page 1047 ? register group 5: ? ?fault mode register? on page 1022 ? ?fault protection value register? on page 1025 there are two types of write protect: ? the write protect sw, which can be enabled or disabled. ? the write protect hw, which can just be enabled, only a hardware reset of the pwm controller can disable it. both write protect can be applied independently to a particular register group thanks to the wpcmd and wprg fields in wpcr register. if at least one of the write protect is active, the register group is write-protected. the wpcm d field allows to perform the following actions depending on its value: ? 0: disabling the write protect sw of the register groups of which the wprg bit is at 1. ? 1: enabling the write protect sw of the register groups of which the wprg bit is at 1. ? 2: enabling the write protect hw of the register groups of which the wprg bit is at 1. at any time, the user can know which write protect is active in which register group by the wpsws and wphws fields in the ?write protect status register? on page 1031 (wpsr). if a write access in a write-protected register is detected, then the wpvs bit in the wpsr regis- ter is set and the wpvsrc field indicates in whic h register the write access has been attempted, through its address offset without the two lsbs. the wpvs and wpsr fields are automatically reset after reading the wpsr register.
995 32117b?avr-03/11 at32uc3c 33.7 user interface table 33-3. pwm register memory map (2) offset register register name access reset 0x000 clock register clk read/write 0x00000000 0x004 enable register ena write-only ? 0x008 disable register dis write-only ? 0x00c status register sr read-only 0x00000000 0x010 interrupt enable register 1 ier1 write-only ? 0x014 interrupt disable register 1 idr1 write-only ? 0x018 interrupt mask register 1 imr1 read-only 0x00000000 0x01c interrupt status regi ster 1 isr1 read-only 0x00000000 0x020 sync channels mode register scm read/write 0x00000000 0x024 reserved ? ? ? 0x028 sync channels update contro l register scuc read/write 0x00000000 0x02c sync channels update period register scup read/write 0x00000000 0x030 sync channels update period updat e register scupupd write-only 0x00000000 0x034 interrupt enable register 2 ier2 write-only ? 0x038 interrupt disable register 2 idr2 write-only ? 0x03c interrupt mask register 2 imr2 read-only 0x00000000 0x040 interrupt status regi ster 2 isr2 read-only 0x00000000 0x044 output override value register oov read/write 0x00000000 0x048 output selection regi ster os read/write 0x00000000 0x04c output selection set register oss write-only ? 0x050 output selection clear register osc write-only ? 0x054 output selection set update register ossupd write-only ? 0x058 output selection clear up date register oscupd write-only ? 0x05c fault mode register fmr read/write 0x00000000 0x060 fault status register fsr read-only 0x00000000 0x064 fault clear register fcr write-only ? 0x068 fault protection value register fpv read/write 0x00000000 0x6c fault protection enable register fpe read/write 0x00000000 0x070-0x078 reserved ? ? ? 0x07c event line 0 mode regi ster el0mr read/write 0x00000000 0x080 event line 1 mode regi ster el1mr read/write 0x00000000 0x084 - 0x0e0 reserved ? ? ? 0x0b0 pwm stepper motor mode register smmr read/write 0x000000000 0x0b4 - 0x0e0 reserved ? ? ?
996 32117b?avr-03/11 at32uc3c 0x0e4 write protect control register wpcr write-only ? 0x0e8 write protect status register wpsr read-only 0x000000000 0x0ec - 0x0f8 reserved ? ? ? 0x0fc version register version read-only 0x- (1) 0x100 - 0x12c reserved ? ? ? 0x130 comparison 0 value register cmp0v read/write 0x000000000 0x134 comparison 0 value update register cmp0vupd write-only ? 0x138 comparison 0 mode register cmp0m read/write 0x000000000 0x13c comparison 0 mode update register cmp0mupd write-only ? 0x140 comparison 1 value register cmp1v read/write 0x000000000 0x144 comparison 1 value update register cmp1vupd write-only ? 0x148 comparison 1 mode register cmp1m read/write 0x000000000 0x14c comparison 1 mode update register cmp1mupd write-only ? 0x150 comparison 2 value register cmp2v read/write 0x000000000 0x154 comparison 2 value update register cmp2vupd write-only ? 0x158 comparison 2 mode register cmp2m read/write 0x000000000 0x15c comparison 2 mode update register cmp2mupd write-only ? 0x160 comparison 3 value register cmp3v read/write 0x000000000 0x164 comparison 3 value update register cmp3vupd write-only ? 0x168 comparison 3 mode register cmp3m read/write 0x000000000 0x16c comparison 3 mode update register cmp3mupd write-only ? 0x170 comparison 4 value register cmp4v read/write 0x000000000 0x174 comparison 4 value update register cmp4vupd write-only ? 0x178 comparison 4 mode register cmp4m read/write 0x000000000 0x17c comparison 4 mode update register cmp4mupd write-only ? 0x180 comparison 5 value register cmp5v read/write 0x000000000 0x184 comparison 5 value update register cmp5vupd write-only ? 0x188 comparison 5 mode register cmp5m read/write 0x000000000 0x18c comparison 5 mode update register cmp5mupd write-only ? 0x190 comparison 6 value register cmp6v read/write 0x000000000 0x194 comparison 6 value update register cmp6vupd write-only ? 0x198 comparison 6 mode register cmp6m read/write 0x000000000 0x19c comparison 6 mode update register cmp6mupd write-only ? 0x1a0 comparison 7 value register cmp7v read/write 0x000000000 0x1a4 comparison 7 value update register cmp7vupd write-only ? table 33-3. pwm register memory map (2) offset register register name access reset
997 32117b?avr-03/11 at32uc3c note: 1. the reset values are device specific. please refer to the module configuration section at the end of this chapter. 2. some registers are indexed with ?ch_num? index ranging from 0 to 3. 0x1a8 comparison 7 mode register cmp7m read/write 0x000000000 0x1ac comparison 7 mode update register cmp7mupd write-only ? 0x1b0 - 0x1fc reserved ? ? ? 0x200 + ch_num * 0x20 + 0x00 channel mode register cmr read/write 0x000000000 0x200 + ch_num * 0x20 + 0x04 channel duty cycle register cdty read/write 0x000000000 0x200 + ch_num * 0x20 + 0x08 channel duty cycle update register cdtyupd write-only ? 0x200 + ch_num * 0x20 + 0x0c channel period register cprd read/write 0x000000000 0x200 + ch_num * 0x20 + 0x10 channel period update register cprdupd write-only ? 0x200 + ch_num * 0x20 + 0x14 channel counter register ccnt read-only 0x000000000 0x200 + ch_num * 0x20 + 0x18 channel dead time register dt read/write 0x000000000 0x200 + ch_num * 0x20 + 0x1c channel dead time update register dtupd write-only ? table 33-3. pwm register memory map (2) offset register register name access reset
998 32117b?avr-03/11 at32uc3c 33.7.1 clock register name: clk access type: read/write offset: 0x000 reset value: 0x00000000 this register can only be written if the wpsws0 and wphws0 bits are cleared in ?write protect status register? on page 1031 . ? clksel: cck source clock selection 0: the pwm internal clock cck is driven by the master clock clk_pwm. 1: the pwm internal clock cck is driven by the generic clock gclk. caution: after writing clksel to a new value, no write to any pwm registers must be attempted before a delay of 2 master clock periods (clk_pwm). this is the time needed by the pwm to switch the internal clock cck. 31 30 29 28 27 26 25 24 clksel --- preb 23 22 21 20 19 18 17 16 divb 15 14 13 12 11 10 9 8 ---- prea 76543210 diva
999 32117b?avr-03/11 at32uc3c ? prea, preb: clka, clkb source clock selection ? diva, divb: clka, clkb divide factor table 33-4. source clock selection prea, preb divider input clock 0 cck 1 cck/2 2 cck/4 3 cck/8 4 cck/16 5 cck/32 6 cck/64 7 cck/128 8 cck/256 9 cck/512 10 cck/1024 other reserved table 33-5. divide factor diva/divb clka/clkb 0 clka/clkb clock is turned off 1 clka/clkb clock is selected by prea/preb 2 - 255 clka/clkb clock is selected by prea/preb divided by diva/divb factor
1000 32117b?avr-03/11 at32uc3c 33.7.2 enable register name: ena access type: write-only offset: 0x004 reset value: - ? chidx: channel id writing a zero to this bit has no effect. writing a one to this bit will enable the pwm output for channel x. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? ? chid3 chid2 chid1 chid0
1001 32117b?avr-03/11 at32uc3c 33.7.3 disable register name: dis access type: write-only offset: 0x008 reset value: - this register can only be written if the wpsws1 and wphws1 bits are cleared in ?write protect status register? on page 1031 . ? chidx: channel id writing a zero to this bit has no effect. writing a one to this bit will disable the pwm output for channel x. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? ? chid3 chid2 chid1 chid0
1002 32117b?avr-03/11 at32uc3c 33.7.4 status register name: sr access type: read-only offset: 0x00c reset value: 0x00000000 ? chidx: channel id 0: pwm output for channel x is disabled. 1: pwm output for channel x is enabled. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? ? chid3 chid2 chid1 chid0
1003 32117b?avr-03/11 at32uc3c 33.7.5 interrupt enable register 1 name: ier1 access type: write-only offset: 0x010 reset value: - writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 ? ??????? 23 22 21 20 19 18 17 16 ? ? ? ? fchid3 fchid2 fchid1 fchid0 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? ? chid3 chid2 chid1 chid0
1004 32117b?avr-03/11 at32uc3c 33.7.6 interrupt disable register 1 name: idr1 access type: write-only offset: 0x014 reset value: - writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ? ??????? 23 22 21 20 19 18 17 16 ? ? ? ? fchid3 fchid2 fchid1 fchid0 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? ? chid3 chid2 chid1 chid0
1005 32117b?avr-03/11 at32uc3c 33.7.7 interrupt mask register 1 name: imr1 access type: read-only offset: 0x018 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 ? ??????? 23 22 21 20 19 18 17 16 ? ? ? ? fchid3 fchid2 fchid1 fchid0 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? ? chid3 chid2 chid1 chid0
1006 32117b?avr-03/11 at32uc3c 33.7.8 interrupt status register 1 name: isr1 access type: read-only offset: 0x01c reset value: 0x00000000 ? fchidx: fault protection trigger on channel x 0: no new trigger of the fault protection since the last read of the isr1 register. 1: at least one trigger of the fault protecti on since the last read of the isr1 register. ? chidx: counter event on channel x 0: no new counter event has occurred sinc e the last read of the isr1 register. 1: at least one counter event has occurred since the last read of the isr1 register. note: reading isr1 automatica lly clears chidx and fchidx. 31 30 29 28 27 26 25 24 ? ??????? 23 22 21 20 19 18 17 16 ? ? ? ? fchid3 fchid2 fchid1 fchid0 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? ? chid3 chid2 chid1 chid0
1007 32117b?avr-03/11 at32uc3c 33.7.9 sync channe ls mode register name: scm access type: read/write offset: 0x020 reset value: 0x00000000 this register can only be written if the wpsws2 and wphws2 bits are cleared in ?write protect status register? on page 1031 . ? ptrcs: pdca transfer request comparison selection selection of the comparison used to set the wrdy bit and the corresponding pdca transfer request. ? ptrm: pdca transfer request mode ? updm: synchronous channels update mode 0: manual write of double buffer registers and manual update of synchronous channels. the update occurs at the beginning of the next pwm period, when the updulock bit in ?sync channels update control register? on page 1009 is set. 1: manual write of double buffer registers and automatic updat e of synchronous channels. the update occurs when the update period is elapsed. 2: automatic write of duty-cycle update registers by the p dca and automatic update of syn chronous channels. the update occurs when the update period is elapsed. 3: reserved. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 ptrcs ptrm - - updm 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? ? sync3 sync2 sync1 sync0 table 33-6. wrdy bit and pdca transfer request updm ptrm wrdy bit and pdca transfer request 0x the wrdy bit in ?interrupt status register 2? on page 1015 and the pdca transfer request are never set to 1. 1x the wrdy bit in ?interrupt status register 2? on page 1015 is set to 1 as soon as the update period is elapsed, the pdca transfer is never requested. 2 0 the wrdy bit in ?interrupt status register 2? on page 1015 and the pdca transfer is requested as soon as the update period is elapsed. 1 the wrdy bit in ?interrupt status register 2? on page 1015 and the pdca transfer is requested as soon as the selected comparison matches.
1008 32117b?avr-03/11 at32uc3c ? syncx: synchronous channel x 0: channel x is not a synchronous channel. 1: channel x is a synchronous channel.
1009 32117b?avr-03/11 at32uc3c 33.7.10 sync channels update control register name: scuc access type: read/write offset: 0x028 reset value: 0x00000000 ? updulock: synchronous channels update unlock 0: no effect 1: if the updm field is set to ?0? in ?sync channels mode register? on page 1007 , writing the updulock bit to one will trigger the update of the period value, the duty-cycle and the dead-time va lues of synchronous channels at the beginning of the next pwm period. if the updm field is set to ?1? or ?2?, writing the updulock bit to one will trigger only the update of the period value and the dead-time values of synchronous channels. this bit is automatically reset when the update is done. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------updulock
1010 32117b?avr-03/11 at32uc3c 33.7.11 sync channels update period register name: scup access type: read/write offset: 0x02c reset value: 0x00000000 ? uprcnt: update period counter reports the value of the update period counter. ? upr: update period defines the time between each update of the synchronous channel s if automatic trigger of the update is activated (updm=1 of updm=2 in ?sync channels mode register? on page 1007 ). this time is equal to upr+1 periods of the synchronous channels. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 uprcnt upr
1011 32117b?avr-03/11 at32uc3c 33.7.12 sync channels update period update register name: scupupd access type: write-only offset: 0x030 reset value: - this register acts as a double buffer for the upr value. this prevents an unexpected automatic trigger of the update of syn- chronous channels. ? uprupd: update period update defines the requested time between each update of the synchrono us channels if automatic trigger of the update is activated (updm=1 of updm=2 in ?sync channels mode register? on page 1007 ). this time is equal to upr+1 periods of the synchronous channels. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ---- uprupd
1012 32117b?avr-03/11 at32uc3c 33.7.13 interrupt enable register 2 name: ier2 access type: write-only offset: 0x034 reset value: - writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 cmpu7 cmpu6 cmpu5 cmpu4 cmpu3 cmpu2 cmpu1 cmpu0 15 14 13 12 11 10 9 8 cmpm7 cmpm6 cmpm5 cmpm4 cmpm3 cmpm2 cmpm1 cmpm0 76543210 ----unre--wrdy
1013 32117b?avr-03/11 at32uc3c 33.7.14 interrupt disable register 2 name: idr2 access type: write-only offset: 0x038 reset value: - writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 cmpu7 cmpu6 cmpu5 cmpu4 cmpu3 cmpu2 cmpu1 cmpu0 15 14 13 12 11 10 9 8 cmpm7 cmpm6 cmpm5 cmpm4 cmpm3 cmpm2 cmpm1 cmpm0 76543210 ----unre--wrdy
1014 32117b?avr-03/11 at32uc3c 33.7.15 interrupt mask register 2 name: imr2 access type: read-only offset: 0x03c reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 cmpu7 cmpu6 cmpu5 cmpu4 cmpu3 cmpu2 cmpu1 cmpu0 15 14 13 12 11 10 9 8 cmpm7 cmpm6 cmpm5 cmpm4 cmpm3 cmpm2 cmpm1 cmpm0 76543210 ----unre--wrdy
1015 32117b?avr-03/11 at32uc3c 33.7.16 interrupt status register 2 name: isr2 access type: read-only offset: 0x040 reset value: 0x00000000 ? cmpux: comparison x update 0: the comparison x has not been updated si nce the last read of the isr2 register. 1: the comparison x has been updated at least one ti me since the last read of the isr2 register. ? cmpmx: comparison x match 0: the comparison x has not matched sinc e the last read of the isr2 register. 1: the comparison x has matched at least one ti me since the last read of the isr2 register. ? unre: synchronous channels update underrun error 0: no synchronous channels update underrun has occu rred since the last read of the isr2 register. 1: at least one synchronous channels update underrun ha s occurred since the last read of the isr2 register. ? wrdy: write ready for synchronous channels update 0: new duty-cycle and dead-time values for the synchronous channels cannot be written. 1: new duty-cycle and dead-time values for the synchronous channels can be written. note: reading isr2 automatically clears wrdy, unre and cmpsx. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 cmpu7 cmpu6 cmpu5 cmpu4 cmpu3 cmpu2 cmpu1 cmpu0 15 14 13 12 11 10 9 8 cmpm7 cmpm6 cmpm5 cmpm4 cmpm3 cmpm2 cmpm1 cmpm0 76543210 ----unre--wrdy
1016 32117b?avr-03/11 at32uc3c 33.7.17 output override value register name: oov access type: read/write offset: 0x044 reset value: 0x00000000 ? oovlx: output override value for pwml output of the channel x 0: override value is 0 for pwml output of channel x. 1: override value is 1 for pwml output of channel x. ? oovhx: output override value for pwmh output of the channel x 0: override value is 0 for pwmh output of channel x. 1: override value is 1 for pwmh output of channel x. 31 30 29 28 27 26 25 24 ? ??????? 23 22 21 20 19 18 17 16 ? ? ? ? oovl3 oovl2 oovl1 oovl0 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? ? oovh3 oovh2 oovh1 oovh0
1017 32117b?avr-03/11 at32uc3c 33.7.18 output selection register name: os access type: read/write offset: 0x048 reset value: 0x00000000 ? oslx: output selection for pwml output of the channel x 0: dead-time generator output dtolx selected as pwml output of channel x. 1: output override value oovlx selected as pwml output of channel x. ? oshx: output selection for pw mh output of the channel x 0: dead-time generator output dtohx se lected as pwmh output of channel x. 1: output override value oovhx selected as pwmh output of channel x. 31 30 29 28 27 26 25 24 ? ??????? 23 22 21 20 19 18 17 16 ? ? ? ? osl3 osl2 osl1 osl0 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? ? osh3 osh2 osh1 osh0
1018 32117b?avr-03/11 at32uc3c 33.7.19 output selection set register name: oss access type: write-only offset: 0x04c reset value: - ? osslx: output selection set for pwml output of the channel x writing a zero to this bit has no effect. writing a one to this bit will override the pwml output of channel x with the oovlx value. ? osshx: output selection set for pwmh output of the channel x writing a zero to this bit has no effect. writing a one to this bit will override the pw mh output of channel x with the oovhx value. 31 30 29 28 27 26 25 24 ? ??????? 23 22 21 20 19 18 17 16 ? ? ? ? ossl3 ossl2 ossl1 ossl0 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? ? ossh3 ossh2 ossh1 ossh0
1019 32117b?avr-03/11 at32uc3c 33.7.20 output selection clear register name: osc access type: write-only offset: 0x050 reset value: - ? osclx: output selection clear for pwml output of the channel x writing a zero to this bit has no effect. writing a one to this bit will override the pwml output of channel x with the dtolx value. ? oschx: output selection clear for pwmh output of the channel x writing a zero to this bit has no effect. writing a one to this bit will override the pw mh output of channel x with the dtohx value. 31 30 29 28 27 26 25 24 ? ??????? 23 22 21 20 19 18 17 16 ? ? ? ? oscl3 oscl2 oscl1 oscl0 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? ? osch3 osch2 osch1 osch0
1020 32117b?avr-03/11 at32uc3c 33.7.21 output selecti on set update register name: ossupd access type: write-only offset: 0x054 reset value: - ? ossuplx: output selection set fo r pwml output of the channel x writing a zero to this bit has no effect. writing a one to this bit will override the pwml output of channe l x with the oovlx value at the beginning of the next channel x pwm period. ? ossuphx: output selection set fo r pwmh output of the channel x writing a zero to this bit has no effect. writing a one to this bit will override the pwmh output of cha nnel x with the oovhx value at the beginning of the next channel x pwm period. 31 30 29 28 27 26 25 24 ? ??????? 23 22 21 20 19 18 17 16 ? ? ? ? ossupl3 ossupl2 ossupl1 ossupl0 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? ? ossuph3 ossuph2 ossuph1 ossuph0
1021 32117b?avr-03/11 at32uc3c 33.7.22 output selection clear update register name: oscupd access type: write-only offset: 0x058 reset value: - ? oscuplx: output selection clear for pwml output of the channel x writing a zero to this bit has no effect. writing a one to this bit will override the pwml output of ch annel x with the dtolx value at the beginning of the next channel x pwm period. ? oscuphx: output selection clear for pwmh output of the channel x writing a zero to this bit has no effect. writing a one to this bit will override the pwmh output of cha nnel x with the dtohx value at the beginning of the next channel x pwm period. 31 30 29 28 27 26 25 24 ? ??????? 23 22 21 20 19 18 17 16 ? ? ? ? oscupl3 oscupl2 oscupl1 oscupl0 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? ? oscuph3 oscuph2 oscuph1 oscuph0
1022 32117b?avr-03/11 at32uc3c 33.7.23 fault mode register name: fmr access type: read/write offset: 0x05c reset value: 0x00000000 this register can only be written if the wpsws5 and wphws5 bits are cleared in ?write protect status register? on page 1031 . ? ffily: fault y filtering 0: the fault input y is not filtered. 1: the fault input y is filtered. ? fmody: fault y activation mode 0: the fault y is active as long as the fault input x is at fpoly. 1: the fault y becomes active as soon as the fault input y is at fpoly level. the fault y stays active until the fault input y is not at fpoly level and until it is cleared in ?fault clear register? on page 1024 . ? fpoly: fault y polarity 0: the fault y becomes active when the fault input y is set to 0. 1: the fault y becomes active when the fault input y is set to 1. caution: to prevent an unexpected activation of the fsy bit in the ?fault status resister? on page 1023 , the fmody bit can be set to one only if the fpoly bit has been previously configured to its final value. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 ffil7 ffil6 ffil5 ffil4 ffil3 ffil2 ffil1 ffil0 15 14 13 12 11 10 9 8 fmod7 fmod6 fmod5 fmod4 fmod3 fmod2 fmod1 fmod0 76543210 fpol7 fpol6 fpol5 fpol4 fpol3 fpol2 fpol1 fpol0
1023 32117b?avr-03/11 at32uc3c 33.7.24 fault status resister name: fmr access type: read/write offset: 0x060 reset value: 0x00000000 ? fsy: fault y status 0: the fault y is not currently active. 1: the fault y is currently active. ? fivy: fault input y value 0: the current sampled value of the fault inpu t y is zero (after filtering if enabled). 1: the current sampled value of the fault i nput y is one (after filtering if enabled). 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 fs7 fs6 fs5 fs4 fs3 fs2 fs1 fs0 76543210 fiv7 fiv6 fiv5 fiv4 fiv3 fiv2 fiv1 fiv0
1024 32117b?avr-03/11 at32uc3c 33.7.25 fault clear register name: fcr access type: write-only offset: 0x064 reset value: - ? fclry: fault y clear writing a zero to this bit has no effect. if the fmody bit is set to one and if the fault input y is not at the level defined by the fpoly bit, then writing a one to thi s bit will clear the fault and the fault becomes inactive (fmody and fpoly bits are located in ?fault mode register? on page 1022 ), else writing a one to this bit has no effect. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 fclr7 fclr6 fclr5 fclr4 fclr3 fclr2 fclr1 fclr0
1025 32117b?avr-03/11 at32uc3c 33.7.26 fault protection value register name: fpv access type: read/write offset: 0x068 reset value: 0x00000000 this register can only be written if the wpsws5 and wphws5 bits are cleared in ?write protect status register? on page 1031 . ? fpvlx: fault protection value fo r pwml output on channel x 0: pwml output of channel x is forced to 0 when fault occurs. 1: pwml output of channel x is forced to 1 when fault occurs. ? fpvhx: fault protection value for pwmh output on channel x 0: pwmh output of channel x is forced to 0 when fault occurs. 1: pwmh output of channel x is forced to 1 when fault occurs. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ? ? ? ? fpvl3 fpvl2 fpvl1 fpvl0 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? ? fpvh3 fpvh2 fpvh1 fpvh0
1026 32117b?avr-03/11 at32uc3c 33.7.27 fault protection enable register name: fpe access type: read/write offset: 0x06c reset value: 0x00000000 this register can only be written if the wpsws5 and wphws5 bits are cleared in ?write protect status register? on page 1031 . only the first 5 bits (number of fault input pins) of fpe0, fpe1, fpe2 and fpe3 are significant. ? fpex[y]: fault protection enable with fault y for channel x 0: fault y is not used for the fault protection of the channel x. 1: fault y is used for the fault protection of the channel x. caution: to prevent an unexpected activation of the fault protec tion, the fpex[y] bit can be written to one only if the fpoly bit has been previously configured to its final value in ?fault mode register? on page 1022 . 31 30 29 28 27 26 25 24 fpe3 23 22 21 20 19 18 17 16 fpe2 15 14 13 12 11 10 9 8 fpe1 76543210 fpe0
1027 32117b?avr-03/11 at32uc3c 33.7.28 event line x register name: elxmr access type: read/write offset: 0x080 + [x * 0x04] reset value: 0x00000000 ? csely: comparison y selection 0: a pulse is not generated on the ev ent line x when the comparison y matches. 1: a pulse is generated on the event line x when the comparison y matches. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 csel7 csel6 csel5 csel4 csel3 csel2 csel1 csel0
1028 32117b?avr-03/11 at32uc3c 33.7.29 stepper motor mode register name: smmr access type: read/write offset: 0x0b0 reset value: 0x00000000 ? gcenx: gray count enable 0: disable gray count on pwml[2*x], pwmh[2*x], pwml[2*x+1], pwmh[2*x+1]. 1: enable gray count on pwml[2*x], pwmh[2*x], pwml[2*x +1], pwmh[2*x+1]. ? downx: down count 0: up counter. 1: down counter. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 - - - - - - down1 down0 15 14 13 12 11 10 9 8 -------- 76543210 ------gcen1gcen0
1029 32117b?avr-03/11 at32uc3c 33.7.30 write protect control register name: wpcr access type: write-only offset: 0x0e4 reset value: - ? wpkey: write protect key should be written at value 0x50574d (?pwm? in ascii). writing any other value in this field abor ts the write op eration of the wpcmd field. always reads as 0. ? wprgx: write protect register group x writing a zero to this bit has no effect. writing a one to this bit will allow to set the wpcmd command to the register group x. ? wpcmd: write protect command this command is performed only if the wpkey value is correct. 0: disable the write protect sw of the register groups of which the wprgx bit is set to 1. 1: enable the write protect sw of the register groups of which the wprgx bit is set to 1. 2: enable the write protect hw of the register groups of which the wprgx bit is set to 1. 3: no effect. note: only a hardware reset of the pwm controller can disable the write protect hw. list of register groups: ? register group 0: ? ?clock register? on page 998 ? register group 1: ? ?disable register? on page 1001 ? register group 2: ? ?sync channels mode register? on page 1007 ? ?channel mode register? on page 1037 ? ?stepper motor mode register? on page 1028 ? register group 3: 31 30 29 28 27 26 25 24 wpkey 23 22 21 20 19 18 17 16 wpkey 15 14 13 12 11 10 9 8 wpkey 76543210 wprg5wprg4wprg3wprg2wprg1wprg0 wpcmd
1030 32117b?avr-03/11 at32uc3c ? ?channel period register? on page 1041 ? ?channel period update register? on page 1043 ? register group 4: ? ?channel dead time register? on page 1046 ? ?channel dead time update register? on page 1047 ? register group 5: ? ?fault mode register? on page 1022 ? ?fault protection value register? on page 1025 ?
1031 32117b?avr-03/11 at32uc3c 33.7.31 write protect status register name: wpsr access type: read-only offset: 0x0e8 reset value: 0x00000000 ? wpvsrc: write protect violation source when wpvs is active, this field indicates the write- protected register (through address offs et divided by four) in which a writ e access has been attempted. ? wphwsx: write protect hw status 0: the write protect hw x of the register group x is disabled. 1: the write protect hw x of the register group x is enabled. ? wpvs: write protect violation status 0: no write protect violation has occurred since the last read of the wpsr register. 1: at least one write protect vi olation has occurred since the la st read of the wpsr register. if this violation is an unauthor ized attempt to write a protected register, the asso ciated violation is reported into wpvsrc field. ? wpswsx: write protect sw status 0: the write protect sw x of the register group x is disabled. 1: the write protect sw x of the register group x is enabled. note: reading wpsr automatically clears wpvs and wpvsrc fields. 31 30 29 28 27 26 25 24 wpvsrc 23 22 21 20 19 18 17 16 wpvsrc 15 14 13 12 11 10 9 8 - - wphws5 wphws4 wphws3 wphws2 wphws1 wphws0 76543210 wpvs - wpsws5 wpsws4 wpsws3 wpsws2 wpsws1 wpsws0
1032 32117b?avr-03/11 at32uc3c 33.7.32 version register register name: version access type: read-only offset: 0x0fc reset value: - ?mfn reserved. no functionality associated. ? version version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 ----- mfn 15 14 13 12 11 10 9 8 ---- version 76543210 version
1033 32117b?avr-03/11 at32uc3c 33.7.33 comparison x value register name: cmpxv access type: read/write offset: 0x130 + [x * 0x10] reset value: 0x00000000 only the first 20 bits (channel counter size) of cv field are significant. ? cvm: comparison x value mode 0: the comparison x between the counter of the channel 0 and the comparison x value is performed when this counter is incrementing. 1: the comparison x between the counter of the channel 0 and the comparison x value is performed when this counter is decrementing. note: this bit is useless if the counter of the channel 0 is left aligned (calg=0 in ?channel mode register? on page 1037 ) ? cv: comparison x value defines the comparison x value to be compared with the counter of the channel 0. 31 30 29 28 27 26 25 24 - ------cvm 23 22 21 20 19 18 17 16 cv 15 14 13 12 11 10 9 8 cv 76543210 cv
1034 32117b?avr-03/11 at32uc3c 33.7.34 comparison x value update register name: cmpxvupd access type: write-only offset: 0x134 + [x * 0x10] reset value: - this register acts as a double buffer for the cv and cv m values. this prevents an unexpected comparison x match. only the first 20 bits (channel counter size) of cv upd field are significant. ? cvmupd: comparison x value mode update 0: the comparison x between the counter of the channel 0 and the comparison x value is performed when this counter is incrementing. 1: the comparison x between the counter of the channel 0 and the comparison x value is performed when this counter is decremented. note: this bit is useless if the counter of the channel 0 is left aligned (calg=0 in ?channel mode register? on page 1037 ) ? cvupd: comparison x value update defines the comparison x value to be compared with the counter of the channel 0. caution: to be taken into account, the write of the cmpxvupd register must be followed by a write of the cmpxmupd register. 31 30 29 28 27 26 25 24 - ------cvmupd 23 22 21 20 19 18 17 16 cvupd 15 14 13 12 11 10 9 8 cvupd 76543210 cvupd
1035 32117b?avr-03/11 at32uc3c 33.7.35 comparison x mode register name: cmpxm access type: read/write offset: 0x138 + [x * 0x10] reset value: 0x00000000 ? cuprcnt: comparison x update period counter reports the value of the comparison x update period counter. note: the cuprcnt field is read-only. ? cupr: comparison x update period defines the time between each update of the comparison x mode and the comparison x value. this time is equal to cupr+1 periods of the channel 0 counter. ? cprcnt: comparison x period counter reports the value of the comparison x period counter. note: the cprcnt field is read-only. ? cpr: comparison x period defines the maximum value of the comparison x period counter (cprcnt). the comparison x value is performed periodically once every cpr+1 periods of the channel 0 counter. ? ctr: comparison x trigger the comparison x is performed when the value of the comparison x period counter (cprcnt) reaches the value defined by ctr. ? cen: comparison x enable 0: the comparison x is disabled and can not match. 1: the comparison x is enabled and can match. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 cuprcnt cupr 15 14 13 12 11 10 9 8 cprcnt cpr 76543210 ctr - - - cen
1036 32117b?avr-03/11 at32uc3c 33.7.36 pwm comparison x mode update register name: cmpxmupd access type: write-only offset: 0x13c + [x * 0x10] reset value: - this register acts as a double buffer for the cen, ctr, cpr and cupr values. this prevents an unexpected comparison x match. ? cuprupd: comparison x update period update defines the time between each update of the comparison x mode and the comparison x value. this time is equal to cupr+1 periods of the channel 0 counter. ? cprupd: comparison x period update defines the maximum value of the comparison x period counter (cprcnt). the comparison x value is performed periodically once every cpr+1 periods of the channel 0 counter. ? ctrupd: comparison x trigger update the comparison x is performed when the value of the comparison x period counter (cprcnt) reaches the value defined by ctr. ? cenupd: comparison x enable update 0: the comparison x is disabled and can not match. 1: the comparison x is enabled and can match. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 ---- cuprupd 15 14 13 12 11 10 9 8 - - - - cprupd 76543210 ctrupd - - - cenupd
1037 32117b?avr-03/11 at32uc3c 33.7.37 channel mode register name: cmr access type: read/write offset: 0x200 + [ch_num * 0x20] reset value: 0x00000000 this register can only be written if the wpsws2 and wphws2 bits are cleared in ?write protect status register? on page 1031 . ? dtli: dead-time pwmlx output inverted 0: the dead-time pwmlx output is not inverted. 1: the dead-time pwmlx output is inverted. ? dthi: dead-time pwmhx output inverted 0: the dead-time pwmhx output is not inverted. 1: the dead-time pwmhx output is inverted. ? dte: dead-time generator enable 0: the dead-time generator is disabled. 1: the dead-time generator is enabled. ? ces: counter ev ent selection the ces bit defines when the channel counter event occu rs when the period is center aligned (chidx in the ?interrupt status register 1? on page 1006 ). calg=0 (left alignment): 0/1: the channel counter event occu rs at the end of the pwm period. calg=1 (center alignment): 0: the channel counter event occurs at the end of the pwm period. 1: the channel counter event occurs at the end of the pwm period and at half the pwm period. ? cpol: channel polarity 0: the ocx output waveform (output from the comparator) starts at a low level. 1: the ocx output waveform (output from the comparator) starts at a high level. ? calg: channel alignment 0: the period is left aligned. 1: the period is center aligned. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 - - - - - dtli dthi dte 15 14 13 12 11 10 9 8 - - - - - ces cpol calg 76543210 - - - - cpre
1038 32117b?avr-03/11 at32uc3c ? cpre: channel pre-scaler table 33-7. channel pre-scaler cpre channel pre-scaler 0 cck 1 cck/2 2 cck/4 3 cck/8 4 cck/16 5 cck/32 6 cck/64 7 cck/128 8 cck/256 9 cck/512 10 cck/1024 11 clka 12 clkb other reserved
1039 32117b?avr-03/11 at32uc3c 33.7.38 channel duty cycle register name: cdty access type: read/write offset: 0x204 + [ch_num * 0x20] reset value: 0x00000000 only the first 20 bits (channel counter size) are significant. ? cdty: channel duty-cycle defines the waveform duty-cycle. this value must be defined between 0 and cprd (cprx). 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 cdty 15 14 13 12 11 10 9 8 cdty 76543210 cdty
1040 32117b?avr-03/11 at32uc3c 33.7.39 channel duty cycle update register name: cdtyupd access type: write-only offset: 0x208 + [ch_num * 0x20] reset value: - this register acts as a double buffer for the cdty value. this prevents an unexpected waveform when modifying the wave- form duty-cycle. only the first 20 bits (channel counter size) are significant. ? cdtyupd: channel duty-cycle update defines the waveform duty-cycle. this value must be defined between 0 and cprd (cprx). 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 cdtyupd 15 14 13 12 11 10 9 8 cdtyupd 76543210 cdtyupd
1041 32117b?avr-03/11 at32uc3c 33.7.40 channel period register name: cprd access type: read/write offset: 0x20c + [ch_num * 0x20] reset value: 0x00000000 this register can only be written if the wpsws3 and wphws3 bits are cleared in ?write protect status register? on page 1031 . only the first 20 bits (channel counter size) are significant. ? cprd: channel period if the waveform is left-aligned, then the output waveform period depends on the channel counter source clock and can be calculated: ? by using the pwm internal clock (cck) divided by an x given pr escaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). the resulting period formula will be: ? by using the pwm internal clock (cck) divided by one of both diva or divb divider, the formula becomes, respectively: or if the waveform is center-aligned, then the output waveform period depends on the channel counter source clock and can be calculated: ? by using the pwm internal clock (cck) divided by an x given pr escaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). the resulting period formula will be: 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 cprd 15 14 13 12 11 10 9 8 cprd 76543210 cprd xcprd () cck ------------------------------- crpd diva () cck ------------------------------------------ crpd divb () cck ------------------------------------------ 2 x cprd () cck ---------------------------------------- -
1042 32117b?avr-03/11 at32uc3c ? by using the pwm internal clock (cck) divided by one of both diva or divb divider, the formula becomes, respectively: or 2 cprd diva () cck --------------------------------------------------- - 2 cprd divb () cck --------------------------------------------------- -
1043 32117b?avr-03/11 at32uc3c 33.7.41 channel period update register name: cprdupd access type: write-only offset: 0x210 + [ch_num * 0x20] reset value: - this register can only be written if the wpsws3 and wphws3 bits are cleared in ?write protect status register? on page 1031 . this register acts as a double buffer for the cprd value. this prevents an unexpected waveform when modifying the waveform period. only the first 20 bits (channel counter size) are significant. ? cprdupd: channel period update if the waveform is left-aligned, then the output waveform period depends on the channel counter source clock and can be calculated: ? by using the pwm internal clock (cck) divided by an x given pr escaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). the resulting period formula will be: ? by using the pwm internal clock (cck) divided by one of both diva or divb divider, the formula becomes, respectively: or if the waveform is center-aligned, then the output waveform period depends on the channel counter source clock and can be calculated: ? by using the pwm internal clock (cck) divided by an x given pr escaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). the resulting period formula will be: 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 cprdupd 15 14 13 12 11 10 9 8 cprdupd 76543210 cprdupd x cprdupd () cck -------------------------------------------- crpdupd diva () cck ------------------------------------------------------- - crpdupd divb () cck ------------------------------------------------------- -
1044 32117b?avr-03/11 at32uc3c ? by using the pwm internal clock (cck) divided by one of both diva or divb divider, the formula becomes, respectively: or 2 x cprdupd () cck ------------------------------------------------------ 2 cprdupd diva () cck ----------------------------------------------------------------- 2 cprdupd divb () cck -----------------------------------------------------------------
1045 32117b?avr-03/11 at32uc3c 33.7.42 channel counter register name: ccnt access type: read-only offset: 0x214 + [ch_num * 0x20] reset value: 0x00000000 only the first 20 bits (channel counter size) are significant. ? cnt: channel counter register gives the channel counter value. this register is reset w hen the channel counter reaches the cprd value defined in the cprdx register if the waveform is left aligned. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 cnt 15 14 13 12 11 10 9 8 cnt 76543210 cnt
1046 32117b?avr-03/11 at32uc3c 33.7.43 channel dead time register name: dt access type: read/write offset: 0x218 + [ch_num * 0x20] reset value: 0x00000000 this register can only be written if the wpsws4 and wphws4 bits are cleared in ?write protect status register? on page 1031 . only the first 16 bits (dead-time counter size) of dth and dtl fields are significant. ? dtl: dead-time valu e for pwmlx output defines the dead-time value for pwmlx output. this value must be defined bet ween 0 and cdty (cdtyx). ? dth: dead-time value for pwmhx output defines the dead-time value for pwmhx output. this val ue must be defined between 0 and cprd-cdty (cprx and cdtyx). 31 30 29 28 27 26 25 24 dtl 23 22 21 20 19 18 17 16 dtl 15 14 13 12 11 10 9 8 dth 76543210 dth
1047 32117b?avr-03/11 at32uc3c 33.7.44 channel dead time update register name: dtupd access type: write-only offset: 0x21c + [ch_num * 0x20] reset value: - this register can only be written if the wpsws4 and wphws4 bits are cleared in ?write protect status register? on page 1031 . this register acts as a double buffer for the dth and dtl va lues. this prevents an unexpected waveform when modifying the dead-time values. only the first 16 bits (dead-time counter size) of dthupd and dtlupd fields are significant. ? dtlupd: dead-time value update for pwmlx output defines the dead-time value for pwmlx output. this value mu st be defined between 0 and cdt y (cdtyx). this value is applied only at the beginning of the next channel x pwm period. ? dthupd: dead-time value update for pwmhx output defines the dead-time value for pwmhx output. this val ue must be defined between 0 and cprd-cdty (cprx and cdtyx). this value is applied only at the beginning of the next channel x pwm period. 31 30 29 28 27 26 25 24 dtlupd 23 22 21 20 19 18 17 16 dtlupd 15 14 13 12 11 10 9 8 dthupd 76543210 dthupd
1048 32117b?avr-03/11 at32uc3c 33.8 module configuration the specific configuration for each pwm instance is listed in the following tables. the module bus clocks listed here are connected to the syst em bus clocks. please refer to the power man- ager chapter for details. 33.8.1 pwm fault sources the following table define the mapping of the pwm fault sources. for details on pwm faults, see fault protection paragraph in the pwm chapter. table 33-8. pwm clock name module name clock name description pwm clk_pwm peripheral bus clock from the pba clock domain gclk the generic clock used for the pwm is gclk4 table 33-9. register reset values register reset value version 0x00000501 table 33-10. pwm fault sources fault input number description 0 pevc channel output 8, this fault is only usable when the fmr.fmody is set to 1. 1 pevc channel output 9, this fault is only usable when the fmr.fmody is set to 1. 2 ext_faults[0] input pin, see peripheral multiplexing on i/o line chapter. 3 ext_faults[1] input pin, see peripheral multiplexing on i/o line chapter. 4 clock failure detector of pm, see pm chapter for details.
1049 32117b?avr-03/11 at32uc3c 34. quadrature decoder (qdec) rev.: 1.0.0.0 34.1 features ? handles three input channels: ? two phase signals (qepa, qepb) ? one index pulse (qepi) ? optional digital filter on inputs ? 16-bit position counter and 16-bit revolu tion counter ? 32-bit timer/ counter mode ? software trigger or peri pheral event trigger ? compare function with pe ripheral event generation ? capture function on peripheral event 34.2 overview the qdec is used in rotating motion systems for position and speed detection. it decodes quadrature signals, normally two 90 degrees out-of-phases pulses, into count and direction informations. the quadrature signals are usually generated by a wheel with periodic transparent gaps (a.k.a. lines) and an optical system composed of one light source and 2 sensors. figure 34-1. quadrature signals description the phase signals are labelled qepa and qepb. if qepa leads qepb, the rotation direction is defined as positive. if qepb leads qepa, the rota tion direction is defined as negative. each time a line passes the sensor, a counter register (cnt.pc) is incremented or decremented depending of the rotation direction. a third input signal, qepi, can be used to reset cnt.pc. qdec can count the total number of revolutions. a top value of cnt.pc is written to the position counter top value in the top value register (top.pctop). when cnt.pc counts up to this value, it wraps around to zero and the revo lution counter field ( cnt.rc) is incremented. cnt.rc is decremented when cnt.pc counts dow n and crosses the zero value. cnt.pc will then be reset to the value in top.pctop. qepa qepb qepi
1050 32117b?avr-03/11 at32uc3c 34.3 block diagram figure 34-2. qdec block diagram 34.4 i/o lines description 34.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 34.5.1 i/o lines the qdec pins are multiplexed with other peripherals. the user must first program the i/o con- troller to give control of the pins to the qdec. quadrature decoder cnt = position counter/ revolution counter cap register cmp register qepa qepb qepi qpulse dir pb compare event capture event trigger event filter filter filter qcf.filten clock control top register clk_qdec_int advanced filter gclk_qdec table 34-1. i/o lines description pin name pin description type qepa quadrature phase signal a input qepb quadrature phase signal b input qepi quadrature index signal input
1051 32117b?avr-03/11 at32uc3c 34.5.2 power management if the cpu enters a sleep mode that disables clocks used by the qdec, the qdec will stop functioning and resume operation after the system wakes up from sleep mode. 34.5.3 clocks the qdec has two clocks connected: one peri pheral bus clock (clk_qdec) and one generic clock (gclk_qdec). these clocks are g enerated by the power manager. clk_qdec is enabled at reset, and can be disabled in the power manager. gclk_qdec is used for filtering in qdec mode and is the timer clock in timer mode. it is a generic clock generated by the power manager. the programmer must configure the power manager to enable gclk_qdec. the gclk_qdec frequency must less than half the clk_qdec clock frequency. 34.5.4 interrupts the qdec interrupt request line is connected to t he interrupt controller. using the qdec inter- rupt requires the interrupt controller to be programmed first. 34.5.5 peripheral events the qdec peripheral events are connected via the peripheral event system. refer to the peripheral event system chapter for details. 34.5.6 debug operation when an external debugger forces the cpu into debug mode, the qdec continues normal operation; the timer is not frozen, but peripheral events are masked. in ocd mode, the timer is not frozen and the events are masked. reading the cap register does not clear the reminding of last capture event for the ovr interrupt. if the qdec is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. the qdec peripheral events are masked during debug operation, unless the run in debug bit in the development control register is written to one and the bit corresponding to the qdec is written to one in the peripheral debug regist er (pdbg). please refer to the on-chip debug chapter in the avr32uc technical reference ma nual, and the ocd module configuration sec- tion, for details. 34.6 functional description 34.6.1 basic operation 34.6.1.1 enabling the qdec the qdec is enabled by writing a one to the clock enable bit in the control register (ctrl.clken). this will also enabl e the internal clk_ qdec_int. this clock is generated from gclk_qdec. clk_qdec_int is used in the filter blocks and fo r clocking the counter in timer mode. a soft- ware trigger or peripheral event trigger is needed for clk_qdec_int to start. the clock enable bit in the status register (sr.clken) indicates if the clock is running.
1052 32117b?avr-03/11 at32uc3c figure 34-3. clock control 34.6.1.2 trigger a trigger resets the qdec counter and starts clk_qdec_int. two triggers are possible: ? a software trigger, by writing a one to the software trigger bit in ctrl (ctrl.swtrg). ? trigger peripheral event from the pevc: if enabled by writing a one to the event trigger enable bit in the conf iguration register (cf.evtrge). the qdec counter is reset when the peripheral trigger event occurs. 34.6.1.3 quadrature decoder logic and digital filter the quadrature decoder logic co nverts the 2-phase signals q epa and qepb in a count pulse signal (qpulse) for each transition and a di r signal to indicate the rotation direction. figure 34-4. quadrature description the qepi signal may be used to detect a reference position once per revolution. the 3 inputs (qepa/qepb/qepi) ca n be inverted by writing to appropriate bits in cf. clk_qdec_int pevc trigger ctrl[clken]= 1 a n d set reset ctrl[clken]=0 gclk_qdec a n d sr[clken] q qepa qepb (0,0) (0,1) (1,1) (1,0) {a,b} = 01 00 10 11 decrement counter decrement counter decrement counter decrement counter increment counter increment counter increment counter increment counter
1053 32117b?avr-03/11 at32uc3c 34.6.1.4 position counter the 16-bit position counter is incremented or decremented on every count pulse, generated by the quadrature decoder module. the counti ng direction is displayed in sr.cntdir. if the position counter reaches the top.pctop value when counting up or the 0 value when counting down, the counter wraps around. the position counter roll over (pcro) interrupt is generated. usually, the top.pctop value should always be set to the total number of quadrature states minus one, which is (quadrature_encoder_lines_count *4) -1. 34.6.1.5 index detection the optional index signal qepi may be used to correct the position counter if quadrature states have been missed due to noise. if the index enable bit (cf.idxe) is written to one, detection of the qepi signal will rese t the position counter to 0 on a selected phase of quadrature signals. this selected phase is configured via the detection phase field (cf.idxphs). the index error (idxerr) interrupt is triggered if the index detection occurs and the position counter value is not 0. 34.6.1.6 revolution counter the revolution counter is incremented/decrement ed each time the position counter rolls over. it rolls over when it reac hes the top.rctop value. 34.6.1.7 waveforms figure 34-5. quadrature clock and direction decoding (top.pctop = 4) qepa qepb qpulse cntdir 02 1 3401 2 104321 pc 0 1 0 rc
1054 32117b?avr-03/11 at32uc3c figure 34-6. pc reset by qepi signal (top.pctop = 79, cf.idxphs =?00?, cf.idxe = ?1?) 34.6.1.8 quadrature frequency the clk_qdec clock frequency must be at least two times the qepa and qepb frequency as these signals are synchronized to the clk_qdec clock. to get the maximum available fre- quency on qepa/qepb signal s, the filter on input s should be bypassed. for a 33 mhz peripheral bus cloc k the maximum qepa fr equency is 16.5 mhz. for a wheel with 8192 lines the maximum rotational speed support ed by qdec is 16.5mhz / 8192 = 2014 rps = 120 849 rpm. 34.6.1.9 disabling the qdec the qdec is disabled by wr iting a zero to ctrl.clken. 34.6.2 advanced operation 34.6.2.1 compare register the compare register (cmp) is used to generate an interrupt and a peripheral event when the cnt register reaches the value defined in cmp. if rc compare is enabled (cf.rcce is one), a compare match occurs when rc is equal to rccmp. a peripheral event is generated and the cmp interrupt line is set if enabled. if the pc compare is enabled (cf.pcce is one), a compare match occurs when the pc is equal to pccmp. a peripheral event is generated and the cmp interrupt line is set if enabled. if both rc compare and pc compare are enabled, a compare match occurs when cnt is equal to cmp. a peripheral event is generated and the cmp interrupt line is set if enabled. the compare peripheral event should be mapped th rough the pevc to another peripheral. qepa qepb qpulse qepi 72 74 73 75 0 1 2 3 2 1 0 79 78 pc 010 rc 77 idxerr
1055 32117b?avr-03/11 at32uc3c 34.6.2.2 capture register the capture function saves the qdec counter value in the capture register (cap) when a cap- ture event has occurred. the capture function is enabled if the qdec counter is running. the cap register will not be updat ed with a new value if the prev ious value has not been read. if a capture event occurs and the previous value has not been read, the sr.ovr bit is set. 34.6.2.3 glitch filter the qdec inputs (qepa/qepb/qepi) ar e passed through a glitch filter that is enab led by writ- ing a one to the cf.filten bit. the input sent to the qdec coun ter will toggle if the input is stable for three clk_qdec_int periods. 34.6.2.4 timer/counter mode qdec can be used as a 32-bit/co unter with compare/capt ure capabilities. this timer includes an up/down (upd) mode where the timer counts up or down according to a toggle direction event from the pevc. the timer/counter is available by writing a ze ro to the cf.qdec bit. timer/counter mode uses the same resources as qdec mode: ? the cnt qdec counter ? the top register to reload the cnt value ? the cmp register to generate a compare peripheral event/interrupt ? the cap register to save the cnt value in case of a capture peripheral event occurs ? the clock selection ? the trigger mechanism it does not use the input filters and the index pulse control. the timer/counter includes an up/down mode that is enabled by writing a one to the cf.upd bit.
1056 32117b?avr-03/11 at32uc3c figure 34-7. timer block diagram the user can set the timer count direction by wr iting to the cf.tsdir bit. the counting direction is taken into account when a trigger occurs. the counting direction is shown in sr.cntdir. the user has to set the initial direction of counting by writing to cf.tsdir. when the timer is triggered, i.e. each time a toggle direction event occurs, the counter changes counting direction. if the counter re aches 0, it will be stuck at 0 as lo ng as the counting direction is down. 34.6.3 interrupts the qdec has one interrupt request line connected to the interrupt controller. the sources of this interrupt are: ? the qepi interrupt to detect the index signal. ? the cmp interrupt to detect a compare match. ? the cap interrupt to detect that the qdec counter value has been saved in the cap register due to the capture event. ? the ovr interrupt to detect that a capture event was received without the cap register having been read since the last capture event. in ocd mode, reading the cap register does not clear the memory of the last capture event. ? the pcro interrupt to detect a roll-over of the position counter. in timer/counter mode, the roll over occurs when (pc = 0xffff and rc != rctop), when pc = top.pctop or when rc = rctop. up/down control cnt cap dir pb capture event trigger event toggle direction event cf.upd cf.tsdir clk_qdec_int clock control cmp top compare event gclk_qdec
1057 32117b?avr-03/11 at32uc3c ? the rcro interrupt to detect a roll-over of the revolution counter. ? the idxerr interrupt to detect that the index signal (qepi) is detected and the position counter does not have the expected value (top.pctop if the counter counts up, 1 if the counter counts down). ? the dirinv interrupt occurs when the count direction changes. ? the qderr interrupt occurs when a bad transition in the quadrature signals is detected (for example, from ?00? to ?11?). this could be caused by erroneous programming of the gclk_qdec frequency. ? the trigger interrupt occurs when a trigger event from pevc is detected. it could be used by software to detect a reset of the counters. ? each interrupt source can be enabled by writing a one to the corresponding bit in the interrupt enable register (ier) and disabled by writing a one to the corresponding bit in the interrupt dis- able register (idr). the enable status can be read from the interrupt mask register (imr). the status of the interrupt sources, even if the interrupt is masked, can be read in sr. when an inter- rupt has occurred, it is reset by writing a one to the corresponding bit in the status clear register (scr). 34.6.4 peripheral events the qdec can receive three pe ripheral events from the pe ripheral event controller (pevc): ? the trigger peripheral event starts clk_qdec_int and enables the counter. ? the capture peripheral event captures cnt in the capture register (cap). ? the toggle_dir peripheral event toggles the count direction when the qdec works in timer mode with upd mode active. the qdec can send one event to the pevc: ? the compare peripheral event when the cnt register reaches the compare register (cmp) value. the pevc must be programmed to enable qdec peripheral events.
1058 32117b?avr-03/11 at32uc3c 34.7 user interface table 34-2. qdec register memory map offset register register name access reset 0x00 control register ctrl read/write 0x00000000 0x04 configuration register cf read/write 0x00000000 0x08 counter register cnt read/write 0x00000000 0x0c top value register top read/write 0x00000000 0x10 compare register cmp read/write 0x00000000 0x14 capture register cap read-only 0x00000000 0x18 status register sr read-only 0x00000000 0x1c status clear register scr write-only 0x00000000 0x20 interrupt mask register imr read-only 0x00000000 0x24 interrupt enable register ier write-only 0x00000000 0x28 interrupt disable register idr write-only 0x00000000 0x2c parameter register parameter read-only - (1) 0x30 version register version read-only - (1) 1. the reset values for this register is device specific. please refer to the module configuration section at the end of this ch apter.
1059 32117b?avr-03/11 at32uc3c 34.7.1 control register name: ctrl access type: read/write offset: 0x00 reset value: 0x00000000 ? swtrg: software trigger writing a one to this bit generates a software trigger if ctrl.clken is one. this bit always reads as 0. ? clken: qdec module and clock enable writing a zero to this bit disables the qdec and clk_qdec_int clock. writing a one to this bit enables the qdec and clk_qdec_int clock. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------swtrgclken
1060 32117b?avr-03/11 at32uc3c 34.7.2 configuration register name: cf access type: read/write offset: 0x04 reset value: 0x00000000 ? upd: up/down timer mode 0: up/down functionality in timer mode is disabled 1: up/down functionality in timer mode is ensabled ? tsdir: timer set direction 0: the counters count up in timer mode 1: the counters count down in timer mode the count direction is updated when a trigger (software or hardware) occurs ? filten: input digital filter enable 0: the input digital filter is disabled 1: the input digital filter is enabled ? idxphs: qepi detection phase 0: qepi detection enabled when qepa signal equals 0 and qepb signal equals 0 1: qepi detection enabled when qepa signal equals 0 and qepb signal equals 1 2: qepi detection enabled when qepa signal equals 1 and qepb signal equals 0 3: qepi detection enabled when qepa signal equals 1 and qepb signal equals 1 ? idxinv: qepi phase 0: qepi will not be inverted 1: qepi will be inverted ? phsinvb: qepb phase 0: qepb will not be inverted 1: qepb will be inverted ? phsinva: qepa phase 0: qepa will not be inverted 1: qepa will be inverted ? evtrge: event trigger enable 0: the event trigger function is disabled 1: the event trigger function is enabled 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------updtsdir 15 14 13 12 11 10 9 8 - - filten idxphs idxinv phsinvb phsinva 76543210 - - - evtrge rcce pcce idxe qdec
1061 32117b?avr-03/11 at32uc3c ? rcce: revolution counter compare enable 0: the revolution counter compare is disabled 1: the revolution counter compare is enabled ? pcce: position counter compare enable 0: the position counter compare is disabled 1: the position counter compare is enabled ? idxe: index enable 0: the index signal detection is disabled 1: the index signal detection is enabled ? qdec: qdec mode 0: qdec is in timer mode 1: qdec is in quadrature decoder mode
1062 32117b?avr-03/11 at32uc3c 34.7.3 counter register name: cnt access type: read/write offset: 0x08 reset value: 0x00000000 ? rc: revolution counter the current value of the revolution counter ? pc: position counter the current value of the position counter 31 30 29 28 27 26 25 24 rc[15:8] 23 22 21 20 19 18 17 16 rc[7:0] 15 14 13 12 11 10 9 8 pc[15:8] 76543210 pc[7:0]
1063 32117b?avr-03/11 at32uc3c 34.7.4 top register name: top access type: read/write offset: 0x10 reset value: 0x00000000 ? rctop: revolution counter top value the top value of the revolution counter ? pctop: position counter top value the top value of the position counter 31 30 29 28 27 26 25 24 rctop[15:8] 23 22 21 20 19 18 17 16 rctop[7:0] 15 14 13 12 11 10 9 8 pctop[15:8] 76543210 pctop[7:0]
1064 32117b?avr-03/11 at32uc3c 34.7.5 compare register name: cmp access type: read/write offset: 0x14 reset value: 0x00000000 ? rccmp: revolution counter compare value the revolution counter value that generates a compare event ? pccmp: position counter compare value the position counter value that generates a compare event 31 30 29 28 27 26 25 24 rccmp[15:8] 23 22 21 20 19 18 17 16 rccmp[7:0] 15 14 13 12 11 10 9 8 pccmp[15:8] 76543210 pccmp[7:0]
1065 32117b?avr-03/11 at32uc3c 34.7.6 capture register name: cap access type: read-only offset: 0x18 reset value: 0x00000000 ? rccap: revolution capture the last capture value of the revolution counter ? pccap: position capture the last capture value of the position counter 31 30 29 28 27 26 25 24 rccap[15:8] 23 22 21 20 19 18 17 16 rccap[7:0] 15 14 13 12 11 10 9 8 pccap[15:8] 76543210 pccap[7:0]
1066 32117b?avr-03/11 at32uc3c 34.7.7 status register name: sr access type: read-only offset: 0x1c reset value: 0x00000000 ? clken: qdec counter clock status this bit is cleared when the qdec and clk_qdec_int has been disabled this bit is set when the qdec and clk_qdec_int has been enabled ? cntdir: coun ter direction this bit is cleared when the counter counts up this bit is set when the counter counts down ? trigger: trigger event occurrence this bit is cleared when the corresponding bit in scr is written to one this bit is set when the trigger event has occurred ? qderr: illegal quadrature signals transition this bit is cleared when the corresponding bit in scr is written to one this bit is set when an illegal transition of quadrature signals has occurred ? ovr: overrun capture this bit is cleared when the corresponding bit in scr is written to one this bit is set when the overrun capture event has occurred ? dirinv: count direction inversion this bit is cleared when the corresponding bit in scr is written to one this bit is set when the count direction has changed ? idxerr: index error this bit is cleared when the corresponding bit in scr is written to one this bit is set when an index error has occurred ? rcro: revolution counter roll over this bit is cleared when the corresponding bit in scr is written to one this bit is set when the revolution counter has rolled over ? pcro: position counter roll over this bit is cleared when the corresponding bit in scr is written to one this bit is set when the position counter has rolled over 31 30 29 28 27 26 25 24 - ??????? 23 22 21 20 19 18 17 16 ------clkencntdir 15 14 13 12 11 10 9 8 ------triggerqderr 76543210 ovr dirinv idxerr rcro pcro cap cmp qepi
1067 32117b?avr-03/11 at32uc3c ? cap: counter capture this bit is cleared when the corresponding bit in scr is written to one this bit is set when a capture event has occurred ? cmp: counter compare this bit is cleared when the corresponding bit in scr is written to one this bit is set when compare match occurred ? qepi: index signal detection this bit is cleared when the corresponding bit in scr is written to one this bit is set when an index detection has occurred
1068 32117b?avr-03/11 at32uc3c 34.7.8 status clear register name: scr access type: write-only offset: 0x20 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in sr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????triggerqderr 76543210 ovr dirinv idxerr rcro pcro cap cmp qepi
1069 32117b?avr-03/11 at32uc3c 34.7.9 interrupt mask register name: imr access type: read-only offset: 0x24 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????triggerqderr 76543210 ovr dirinv idxerr rcro pcro cap cmp qepi
1070 32117b?avr-03/11 at32uc3c 34.7.10 interrupt enable register name: ier access type: write-only offset: 0x28 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????triggerqderr 76543210 ovr dirinv idxerr rcro pcro cap cmp qepi
1071 32117b?avr-03/11 at32uc3c 34.7.11 interrupt disable register name: idr access type: write-only offset: 0x2c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????triggerqderr 76543210 ovr dirinv idxerr rcro pcro cap cmp qepi
1072 32117b?avr-03/11 at32uc3c 34.7.12 parameter register name: parameter access type: read-only offset: 0x30 reset value: - ? rcsize: number of bits -1 in cnt.rc registers ?pcsize: number of bits -1 in cnt.pc registers 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 rcsize pcsize
1073 32117b?avr-03/11 at32uc3c 34.7.13 version register name: version access type: read-only offset: 0x34 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???? variant 15 14 13 12 11 10 9 8 ???? version[11:8] 76543210 version[7:0]
1074 32117b?avr-03/11 at32uc3c 34.8 module configuration the specific configuration for each qdec instanc e is listed in the following tables. the module bus clocks listed here are connected to the syst em bus clocks. please refer to the power man- ager chapter for details. table 34-3. qdec clock name module name clock name description qdec0 clk_qdec0 peripheral bus clock from the pba clock domain gclk_qdec0 the generic clock used for the qdec0 is gclk5 qdec1 clk_qdec1 peripheral bus clock from the pba clock domain gclk_qdec1 the generic clock used for the qdec1 is gclk6 table 34-4. register reset values register reset value version 0x00000100 parameter 0x000000ff
1075 32117b?avr-03/11 at32uc3c 35. analog comparator interface (acifa) rev: 1.0.0.0 35.1 features ? control one set of tw o analog comparators ? high speed option versus low power option ? shortest propagation delay/highest current consumption ? longest propagation delay/lowest current consumption ? selectable input hysteresis: ? 0mv, 20mv, 50mv ? input selection between external input pin and internal inputs ? window function ? interrupt on: ? rising edge, falling edge, toggle ? signal above/below window, si gnal inside/outside window ? startup time ? two analog comparators interface events availab le on pin through pevc 35.2 overview the analog comparator interface (acifa) is able to control two analog comparators (ac) with identical behavior. an analog comparator compares two voltages and gives a compare output depending on this comparison. the acifa can be configured in normal mode (see figure 35-1 on page 1076 ) or in window mode (see figure 35-2 on page 1076 ). the ac?s inputs are programmable between inte rnal inputs (dac, voltage reference, ...) and external input pins. according to the comparison result, each comparator can trigger a separate interrupt in normal mode. in window function, an additional interrupt can be triggered, depending if the voltage to be compared is inside or outside the window. the acifa is able to generate two output events that can be used through pevc to trigger a hardware process.
1076 32117b?avr-03/11 at32uc3c 35.3 block diagram figure 35-1. analog comparator interface overview in normal mode figure 35-2. analog comparator interface in window mode a c o u t a - + vipa acan internal inputs acap internal inputs aca - + acbn internal inputs acbp internal inputs acb vina vipb vinb confa.inselp confa.inseln confb.inseln confa.inselp interrupt generator pevc interrupt controller acifa sr.acbcs sr.acacs event generator 0 event generator 1 a c o u t b evsrc1.evsrc evsrc0.evsrc] vcc scale vcc scale acaout acbout acouta - + vipa acan internal inputs acbp acap aca - + acbn internal inputs acb vina vipb vinb acoutb window function low er lim it of window v l upper limit of window v h common input voltage v common confa.inselp wconf.winsel confb.inseln interrupt generator interrupt controller pevc sr.acbcs sr.wfcs sr.acacs acifa event generator 1 event generator 0 evsrc0.evsrc evsrc1.evsrc acwout internal inputs vcc scale acaout acbout
1077 32117b?avr-03/11 at32uc3c 35.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 35.4.1 power management when the acifa is enabled it will remain clocked as long as its selected clock source is running. it can also wake the cpu from the currently active sleep mode. refer to the power manager chapter for details on the different sleep modes. 35.4.2 clocks the clock for the acifa bus interface (clk_a cifa) is generated by the power manager. this clock is turned on by default, and can be enabled and disabled in the power manager. 35.4.3 interrupts the acifa interrupt request lines are connected to the interrupt controller. using the acifa interrupts requires the interrupt controller to be programmed first. 35.4.4 peripheral events the acifa peripheral events are connected via the peripheral event system. refer to the peripheral event system chapter for details. 35.4.5 debug operation the acifa is frozen during debug operation, unless the run in debug bit in the development control register is set and the bit corresponding to the acifa is set in the peripheral debug register (pdbg). please refer to the on-chip debug chapter in the avr32uc technical refer- ence manual, and the ocd module configuration section, for details. 35.5 functional description 35.5.1 normal mode in normal mode, both analog comparators are independent. 35.5.1.1 acifa output an analog comparator generates one output acout[i] (with i = a or b) according to the input volt- ages vip i (ac positive input) and vin i (ac negative input): ? acout[i] = 1 if vip i > vin i ? acout[i] = 0 if vip i < vin i ? acout[i] = 0 if the ac output is not available (ie. the ac ready bit in the status register (sr.acrdyi) is still zero) the acifa generates two independent events according to the configuration of the event source selection field in the event config uration register (evsrc0.evsrc and evsrc1.evsrc): ? as soon as vipa > vina or ? as soon as vipa < vina or ? as soon as vipb > vinb or
1078 32117b?avr-03/11 at32uc3c ? as soon as vipb < vinb or ? on toggle of the aca output (acouta) or ? on toggle of the acb output (acoutb) 35.5.1.2 acifa interrupt each ac has one source of interrupt. the configuration of the source of the interruption is done by writing in the interrupt settings field in the configuration register (conf0.is and conf1.is). the interrupt can be triggered: ? as soon as vip > vin ? as soon as vip < vin ? on toggle of the ac output (acout[i]) 35.5.2 window mode in window mode, the two acs are grouped. the negative input of aca and the positive input of acb are the same and are defined in the wind ow common input selection field in the window configuration register (wconf.winsel). the positive input of aca and the negative input of acb are still configured by co nf0.inselp and conf1.inseln. 35.5.2.1 acifa output like in normal mode, the acs generate the acout[i] outputs according to the input voltages vip i (ac positive input) and vin i (ac negative input): ? acout[i] = 1 if vip i > vin i ? acout[i] = 0 if vip i < vin i ? acout[i] = 0 if the ac output is no t available (ie. sr.acrdyi is still 0) the acifa generates a window function signal (acwout) according to the common input voltage to be compared: ? acwout = 1 if the common input voltage is inside the window, vin b < v common < vip a ? acwout = 0 if the common input voltage is outside the window, v common < vin 1 or v common > vip 0 ? acwout = 0 if the window mode output is not available (ie. the window function ready bit in the status register (sr.wfrdy) is still 0) the acifa generates two independent events (like in normal mode) according to the configura- tion of evsrc0 and evsrc1: ? as soon as vipa > vina or ? as soon as vipa < vina or ? as soon as vipb > vinb or ? as soon as vipb < vinb or ? as soon as vinb < vcommon < vipa or ? as soon as vcommon < vinb or vcommon > vipa or ? on toggle of the aca output (acouta) or ? on toggle of the acb output (acoutb) or ? on toggle of the window compare output (acwout)
1079 32117b?avr-03/11 at32uc3c 35.5.2.2 acifa interrupt like in normal mode, each ac has one source of interrupt. the configuration of the source of interruption is set in conf0.is and co nf1.is. the interrupt can be triggered: ? as soon as vip > vin ? as soon as vip < vin ? on toggle of the ac output (acout[i]) an additional source of interrupt can be generated in window mode. its configuration is set in the window interrupt settings field in the window configuration register (wconf.wis). the source of interrupt can be triggered: ? as soon as the common input voltage is inside the window ? as soon as the common input voltage is outside the window ? on toggle of the window compare output (acwout) 35.5.3 input channels each analog comparator has one positive and one negative input. each input may be chosen among one external input pin in addition to some internal signals. the user writes the input selection: ? in normal mode by writing in the positive input selection field (confi.inselp) and in the negative input selection field in the configuration register (confi.inseln) ? in window mode by writing in the conf0. inselp, wconf.winsel and conf1.inseln fields. in this case the wconf.winsel field overrides the conf0.inseln and conf1.inselp fields. 35.5.4 internal inputs three internal inputs are available for the analog comparator. 35.5.5 high-speed vs low power modes it is possible to enable high-speed mode by writing a one to the speed selection bit in the conf register (confi.ss) to get the shortest possible propagation delay. this mode consumes more power than the default low power mode (when confi.ss is written to zero) that has a lon- ger propagation delay. 35.5.6 input hysteresis the user can select between no, low, and high hysteresis, by writing in the hysteresis selection field in the conf register (confi.hs). adding hysteresis can avoid constant toggling of the compare output if the input signals are very close to each other. 35.5.7 startup time after enabling an analog comparator, the comparison is available after a start-up time defined in the start up time field in the start up time register (sut.sut). during this time the ac output is not available. the status bit sr.acrdyi gives the information that the aci has its output avail- able or not. in window mode the window mode out put is available (sr.wfrdy is one) if both comparator outputs are available (sr.acardy and sr.acbrdy are both one).
1080 32117b?avr-03/11 at32uc3c when the start-up time is finished, the comparison can be disabled/enabled, by writing a one to the corresponding ac comparison enable bit in the enable register (en.accpen), without waiting anymore. 35.5.8 starting signal compare in order to start a voltage comparison, the analog comparator must be configured with the pre- ferred properties and the inputs to be used. after enabling the analog comparator, it should wait for the startup time. when the startup time is over, the result of the comparison is available. it can be read at all times in the sr register.
1081 32117b?avr-03/11 at32uc3c 35.6 user interface notes: 1. the reset values for this register is device specific. please refer to the module configuration section at the end of t his chapter. table 35-1. acifa register memory map offset register register name access reset 0x00 aca configuration register confa read/write 0x80000000 0x04 acb configuration regi ster confb read/write 0x80000000 0x08 ac window function configurat ion register wconf read/write 0x00000000 0x0c ac event 0 source configuration evsrc0 read/write 0x00000000 0x10 ac event 1 source configuration evsrc1 read/write 0x00000000 0x14 aca scale factor selection scfa read/write 0x00000000 0x18 acb scale factor selection scfb read/write 0x00000000 0x1c ac enable register en write-only 0x00000000 0x20 ac disable register dis write-only 0x00000000 0x24 ac startup timer register sut read/write 0x00000000 0x28 ac interrupt enable register ier write-only 0x00000000 0x2c ac interrupt disable register idr write-only 0x00000000 0x30 ac interrupt mask register imr read-only 0x00000000 0x34 ac event enable register eve write-only 0x00000000 0x38 ac event disable register evd write-only 0x00000000 0x3c ac event mask register evm read-only 0x00000000 0x40 ac status register sr read-only 0x00000000 0x44 ac status clear register scr write-only 0x00000000 0x48 version register version read-only - (1)
1082 32117b?avr-03/11 at32uc3c 35.6.1 aca configuration register name: confa access type: read/write offset: 0x00 reset value: 0x80000000 ? oen: output enable ?0?: enable the redirection of the output of ac on pad ?1?: the output redirection is disabled ? ss: speed select 0: the low power mode is selected (longest propagation delay, lowest current consumption) 1: the high-speed mode is selected (shortes t propagation delay, highest current consumption) ? hs: hysteresis select ?00? or ?11?: no hysteresis ?01?: small hysteresis, 20 mv ?10?: high hysteresis, 50 mv ? inseln: negative input select i: select the i th input of the mux ? inselp: positive input select i: select the i th input of the mux ? is: interrupt settings ?00?: the comparator interrupt is set as soon as vip > vin ?01?: the comparator interrupt is set as soon as vip < vin ?10?: the comparator interrupt is set on toggle of analog comparator output 31 30 29 28 27 26 25 24 oen - - ss - - hs 23 22 21 20 19 18 17 16 ---- inseln 15 14 13 12 11 10 9 8 ---- inselp 76543210 ------ is
1083 32117b?avr-03/11 at32uc3c 35.6.2 acb configuration register name: confb access type: read/write offset: 0x04 reset value: 0x80000000 ? oen: output enable ?0?: enable the redirection of the output of ac on pad ?1?: the output redirection is disabled ? ss: speed select 0: the low power mode is selected (longest propagation delay, lowest current consumption) 1: the high-speed mode is selected (shortes t propagation delay, highest current consumption) ? hs: hysteresis select ?00? or ?11?: no hysteresis ?01?: small hysteresis, 20 mv ?10?: high hysteresis, 50 mv ? inseln: negative input select i: select the i th input of the mux ? inselp: positive input select i: select the i th input of the mux ? is: interrupt settings ?00?: the comparator interrupt is set as soon as vip > vin ?01?: the comparator interrupt is set as soon as vip < vin ?10?: the comparator interrupt is set on toggle of analog comparator output 31 30 29 28 27 26 25 24 oen - - ss - - hs 23 22 21 20 19 18 17 16 ---- inseln 15 14 13 12 11 10 9 8 ---- inselp 76543210 ------ is
1084 32117b?avr-03/11 at32uc3c 35.6.3 ac window function configurati on register name: wconf access type: read/write offset: 0x08 reset value: 0x00000000 ? winsel: window functi on common input select i: select the i th input of the mux ? wis: window mode interrupt settings ?00?: the window interrupt is set as soon as the input voltage is inside the window ?01?: the window interrupt is set as soon as the input voltage is outside the window ?10?: the window interrupt is set on toggle of window compare output 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ---- winsel 76543210 ------ wis
1085 32117b?avr-03/11 at32uc3c 35.6.4 ac event 0/1 configuration register name: evsrc0-evsrc1 access type: read/write offset: 0x0c-0x10 reset value: 0x00000000 ? evsrc: event source selection ?0000?: the event is set on aca.acout rising edge ?0001?: the event is set on aca.acout falling edge ?0010?: the event is set on aca.acout rising or falling edge ?0011?: the event is set on acb.acout rising edge ?0100?: the event is set on acb.acout falling edge ?0101?: the event is set on acb.acout rising or falling edge ?0110?: the event is set on acwout rising edge ?0111?: the event is set on acwout falling edge ?1000?: the event is set on acwout rising or falling edge ?1001?,?1010?,?1011?,?1100?,?1101?,?1110?,?1111?: no effect 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ---- evsrc
1086 32117b?avr-03/11 at32uc3c 35.6.5 aca/b scale factor selection register name: scfa-scfb access type: read/write offset: 0x14-0x18 reset value: 0x00000000 ? scf: scale factor selection for supply divider vcc scale = (64 -scf) * vddana / 65 ? en : supply divider enable 0: the supply divider is disabled 1: the supply divider is enabled 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -en scf
1087 32117b?avr-03/11 at32uc3c 35.6.6 ac enable register name: en access type: write-only offset: 0x1c reset value: 0x00000000 ? acbcpen: acb comparison enable writing a zero to this bit has no effect writing a one to this bit will enable the comparison of the analog comparator b ? acacpen: aca comparison enable writing a zero to this bit has no effect writing a one to this bit will enable the comparison of the analog comparator a ? wfen: window function enable writing a zero to this bit has no effect writing a one to this bit will enable the window function. enab ling the window function automatically enable both comparators i f they are not already enabled, and also the two comparison (sr.acaen, sr.acben, sr.acacpen,and sr.acbcpen are set) ? acben: acb enable writing a zero to this bit will has no effect writing a one to this bit will enable the analog comparator b ? acaen: aca enable writing a zero to this bit will has no effect writing a one to this bit will enable the analog comparator a 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - acbcpen acacpen wfen acben acaen
1088 32117b?avr-03/11 at32uc3c 35.6.7 ac disable register name: dis access type: write-only offset: 0x20 reset value: 0x00000000 ? acbcpen: acb comparison enable writing a zero to this bit has no effect writing a one to this bit will disable t he comparison of the analog comparator b ? acacpen: aca comparison enable writing a zero to this bit has no effect writing a one to this bit will disable t he comparison of the analog comparator a ? wfen: window function enable writing a zero to this bit has no effect writing a one to this bit will disable the window function. disab ling the window function automatically disable both comparison (acacpen and acbcpen are cleared) ? acben: acb enable writing a zero to this bit has no effect writing a one to this bit will disable the analog comparator b ? acaen: aca enable writing a zero to this bit has no effect writing a one to this bit will disable the analog comparator a 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - acbcpdis acacpdis wfdis acbdis acadis
1089 32117b?avr-03/11 at32uc3c 35.6.8 ac startup time register name: sut access type: read/write offset: 0x24 reset value: 0x00000000 ? sut: startup time analog comparator startup ti me = 1/freq(acifa) x sut each time, an ac is enabled, the ac comparison will be enab led after the startup time due to the startup time of the ac 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------ sut 76543210 sut
1090 32117b?avr-03/11 at32uc3c 35.6.9 ac interrupt enable register name: ier access type: write-only offset: 0x28 reset value: 0x00000000 ? sutbint: acb startup time interrupt enable writing a zero to this bit has no effect writing a one to this bit will enable the acb startup interrupt ? sutaint: aca startup time interrupt enable writing a zero to this bit has no effect writing a one to this bit will enable the aca startup interrupt ? wfint: window functi on interrupt enable writing a zero to this bit has no effect writing a one to this bit will enable the window function interrupt defined in the wconf.wis field ? acbint: acb interrupt enable writing a zero to this bit has no effect writing a one to this bit will enable the acb interrupt defined in the confb.is field ? acaint: aca interrupt enable writing a zero to this bit has no effect writing a one to this bit will enable the aca interrupt defined in the confa.is field 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - sutbint sutaint wfint acbint acaint
1091 32117b?avr-03/11 at32uc3c 35.6.10 ac interrupt disable register name: idr access type: write-only offset: 0x2c reset value: 0x00000000 ? sutbint: acb startup time interrupt enable writing a zero to this bit has no effect writing a one to this bit will disable the acb startup interrupt ? sutaint: aca startup time interrupt enable writing a zero to this bit has no effect writing a one to this bit will disable the aca startup interrupt ? wfint: window functi on interrupt enable writing a zero to this bit has no effect writing a one to this bit will disable the window function interrupt defined in the wconf.wis field ? acbint: acb interrupt enable writing a zero to this bit has no effect writing a one to this bit will disable the acb interrupt defined in the confb.is field ? acaint: aca interrupt enable writing a zero to this bit has no effect writing a one to this bit will disable the aca interrupt defined in the confa.is field 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - sutbint sutaint wfint acbint acaint
1092 32117b?avr-03/11 at32uc3c 35.6.11 ac interrupt mask register name: imr access type: read-only offset: 0x30 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - sutbint sutaint wfint acbnt acaint
1093 32117b?avr-03/11 at32uc3c 35.6.12 ac event enable register name: eve access type: write-only offset: 0x34 reset value: 0x00000000 ? acev1: event 1 enable writing a zero to this bit has no effect writing a one to this bit will enable the event zero defined in the evsrc1.evscr field ? acev0: event 0 enable writing a zero to this bit has no effect writing a one to this bit will enable the event one defined in the evsrc0.evscr field 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------acev1acev0
1094 32117b?avr-03/11 at32uc3c 35.6.13 ac event disable register name: evd access type: write-only offset: 0x38 reset value: 0x00000000 ? acev1: event 1 enable writing a zero to this bit has no effect writing a one to this bit will disable the event one defined in the evsrc1.evscr field ? acev0: event 0 enable writing a zero to this bit has no effect writing a one to this bit will disable the event one defined in the evsrc0.evscr field 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------acev1acev0
1095 32117b?avr-03/11 at32uc3c 35.6.14 ac event mask register name: evm access type: read-only offset: 0x3c reset value: 0x00000000 0: the corresponding peripheral event is disabled 1: the corresponding peripheral event is enabled theses bits are cleared when the corresponding bit in evd is written to zero these bits are cleared when the corre sponding bit in eve is written to one 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------acev1acev0
1096 32117b?avr-03/11 at32uc3c 35.6.15 ac status register name: sr access type: read-only offset: 0x40 reset value: 0x00000000 ? wfrdy: window function ready this bit is cleared when the window function output (wout) is not ready (one or both aca or acb comparison outputs is not ready) this bit is set when the window function output (wout) is ready (both aca and acb co mparison outputs are ready) ? acbrdy: acb ready this bit is cleared when the acb output (acoutb) is not ready this bit is set when the acb output (acoutb) is ready (acb is enabled and its sut is over) ? acardy: aca ready this bit is cleared when the aca output (acouta) is not ready this bit is set when the aca output (acouta) is ready (aca is enabled and its sut is over) ? wfcs: window function current status this bit is cleared when the common input voltage is currently outside the window this bit is set when the common input voltage is currently inside the window ? acbcs: acb current status of comparison this bit is cleared when v ipb is currently lower than v inb this bit is set when v ipb is currently greater than v inb ? acacs: aca current status of comparison this bit is cleared when v ipa is currently lower than v ina this bit is set when v ipa is currently greater than v ina ? acbcpen: acb comparison enable this bit is cleared when the acb comparison is disabled this bit is set when the acb comparison is enabled ? acacpen: aca comparison enable this bit is cleared when the aca comparison is disabled this bit is set when the aca comparison is enabled 31 30 29 28 27 26 25 24 - - - - - wfrdy acbrdy acardy 23 22 21 20 19 18 17 16 - - - - - wfcs acbcs acacs 15 14 13 12 11 10 9 8 - - - acbcpen acacpen wfen acben acaen 76543210 - - - sutbint sutaint wfint acbnt acaint
1097 32117b?avr-03/11 at32uc3c ? wfen: window function enable this bit is cleared when the window function is disabled this bit is set when the window function is enabled ? acben: acb enable this bit is cleared when the acb is disabled this bit is set when the acb is enabled ? acaen: aca enable this bit is cleared when the aca is disabled this bit is set when the aca is enabled ? sutbint: acb startup time interrupt status this bit is cleared when the acb interrupt is not pending this bit is set when the acb interrupt is pending ( the acb has reached its startup time (sut), the acb comparison is valid) ? sutaint: aca startup time interrupt status this bit is cleared when the aca interrupt is not pending this bit is set when the aca interrupt is pending ( the aca has reached its startup time (sut), the aca comparison is valid) ? wfint: window functi on interrupt status this bit is cleared when the interrupt is not pending this bit is set when the interrupt is pending ? acbint: acb interrupt status this bit is cleared when the interrupt is not pending this bit is set when the interrupt is pending ? acaint: aca interrupt status this bit is cleared when the interrupt is not pending this bit is set when the interrupt is pending
1098 32117b?avr-03/11 at32uc3c 35.6.16 ac status clear register name: scr access type: write-only offset: 0x44 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in sr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - sut1int sut0int wfint acbnt acaint
1099 32117b?avr-03/11 at32uc3c 35.6.17 version register name: version access type: read-only offset: 0x48 reset value: 0x00000000 ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
1100 32117b?avr-03/11 at32uc3c 35.7 module configuration the specific configuration for each acifa instance is listed in the following tables. the module bus clocks listed here are connected to the system bus clocks according to the table in the sys- tem bus clock connections section. the following table gives which acifa module controls the analog comparators. the inputs of the ac are configured through the confa and confb registers. the configura- tion allows to select pin or internal voltage from the dacs. the following table defines the valid settings for the confa and confb registers for each acifa instance. this setting defines the mapping of the ac input voltage. table 35-2. module clock name module name clock name description acifa0 clk_acifa0 peripheral bus clock from the pba clock domain acifa1 clk_acifa1 peripheral bus clock from the pba clock domain table 35-3. register reset values register reset value version 0x00000100 table 35-4. analog comparators controlled by acifa module name analog comparator name acifa0 ac0a and ac0b acifa1 ac1a and ac1b table 35-5. v ip of ac0a selection confa[inselp] name connection 0 ac0ap0 see peripheral multiplexing on i/o line chapter 1 ac0ap1 2 dac0_int internal output of the dac0
1101 32117b?avr-03/11 at32uc3c table 35-6. v in of ac0a selection confa[inseln] name connection 0 ac0an0 see peripheral multiplexing on i/o line chapter 1ac0an1 2 ac0bp0 3 ac0bp1 4v vddana scaled v vddana scaled 5 dac1_int internal output of the dac1 table 35-7. v ip of ac0b selection confb[inselp] name connection 0 ac0an0 see peripheral multiplexing on i/o line chapter 1ac0an1 2 ac0bp0 3 ac0bp1 4 dac0_int internal output of the dac0 5v vddana scaled v vddana scaled table 35-8. v in of ac0b selection confb[inseln] description connection 0 ac0bn0 see peripheral multiplexing on i/o line chapter 1ac0bn1 2 dac1_int internal output of the dac1 table 35-9. v ip of ac1a selection confa[inselp] descri ption connection 0 ac1ap0 see peripheral multiplexing on i/o line chapter 1 ac1ap1 2 dac0_int internal output of the dac0 table 35-10. v in of ac1a selection confa[inseln] description connection 0 ac1an0 see peripheral multiplexing on i/o line chapter 1ac1an1 2 ac1bp0 3 ac1bp1 4v vddana scaled v vddana scaled 5 dac1_int internal output of the dac1
1102 32117b?avr-03/11 at32uc3c in window mode, the window common input is configured through wconf register. table 35-11. v ip of ac1b selection confb[inselp] description connection 0 ac1an0 see peripheral multiplexing on i/o line chapter 1ac1an1 2 ac1bp0 3 ac1bp1 4 dac0_int internal output of the dac0 5v vddana scaled v vddana scaled table 35-12. v in of ac1b selection confb[inseln] description connection 0 ac1bn0 see peripheral multiplexing on i/o line chapter 1ac1bn1 2 dac1_int internal output of the dac1 table 35-13. common input voltage of ac0 selection wconf[winsel] description connection 0 ac0an0 see peripheral multiplexing on i/o line chapter 1ac0an1 2 ac0bp0 3 ac0bp1 table 35-14. common input voltage of ac1 selection wconf[winsel] description connection 0 ac1an0 see peripheral multiplexing on i/o line chapter 1ac1an1 2 ac1bp0 3 ac1bp1
1103 32117b?avr-03/11 at32uc3c 36. adc interface (adcifa) rev. 1.1.0.2 36.1 features ? 8/10/12-bit adc core with built-i n dual sample and hold (s/h) ? 16 channels ? up to 1.5 mega-samples per second conversion rate for 12 bits resolution ? conversion time near to 5.3s ( 12 bits resolution at 1.5 msps) ? up to 2 mega-samples per second conversion for lower resolution ? conversion time near to 3.5s (10 bits resolution at 2 msps) ? conversion time near to 3s (8 bits resolution at 2 msps) ? multiple reference sources ? 1v internal voltage reference ? 0.6 * vddana internal ? two external reference voltage ? direct measures or sampled with sample-and-hold ? sample-and-hold (s/h) acquis ition time window has separate prescale control (gain: 1, 2, 4, 8, 16, 32, 64). ? sequencer can be operated as two independen t 8-state sequencers operating on its own s/h (dual sequencer mode) or as one large 16-s tate sequencer (single sequencer mode) ? 16 result registers ? source selection for the start-of-conversion (soc) ? software ? embedded timer ? peripheral event controller ? continuous ? two sequencer modes: ? run the whole sequence on a start-of-conversion ? run a single conversion on a start-of-conversion ? flexible interrupt control allows interrupt request on every end- of-sequence or on every single conversion. ? windowing mechanism, with selectable channel ? free running mode ? 2 pdca channels (one per sequencer) ? power reduction modes ? programmable adc timings
1104 32117b?avr-03/11 at32uc3c 36.2 overview the analog-to-digital converter (a dc) is fully differential and based on a 12-bit pipelined topol- ogy using switched capacitors circuitry. two sa mple and hold (s/h) running simultaneously with 1, 2, 4, 8, 16, 32, 64 gain factors are feeding a single adc analog block so that the system acts as if there were two conversion running in parallel. it can be configured as a 8-bit 10-bit or 12-bit adc and is capable of converting 1.5 million samples per second thanks to its pipeline topology. 10-bit and 8-bit conversion resolution can be achieved at higher conversion rates. note that results are always sign ed in 2's complement. note: the pipelined topology implies a latency between the sampling event and the update of the result register of: (resolution(sres)/2 + 3 - shd) t(ckadc) the adc has an internal defined conversion range of 1.0v. an additional internal reference mode allows conversion range of 0.6 * vddana. in addition, the adc may operate with exter- nal references for different conversion ranges.
1105 32117b?avr-03/11 at32uc3c 36.3 block diagram figure 36-1. adcifa block diagram pdc sequencer0 sequencer1 12-bit adc core preamp0 s/h preamp1 s/h arbiter adc result1 res8 . . . res15 adc timer adc result0 res0 . . . res7 adc window0 clk_adcifa ckdiv pb adcrefp adcrefn adc_event_ctrl adc window1 clkadc pdc adcref0 adcref1 adcinx adcinx gndana vddana
1106 32117b?avr-03/11 at32uc3c 36.4 i/o lines description 36.5 product dependencies 36.5.1 i/o lines the pins used for interfacing the adcifa may be multiplexed with the i/o controller lines. the programmer must first program the i/o controller to assign the desired adcifa pins to their peripheral function. if i/o lines of the adcifa ar e not used by the application, they can be used for other purposes by the i/o controller. not all adcifa inputs may be enabled. if an a pplication requires only four channels, then only four adcifa lines need to be assigned to adcifa inputs. 36.5.2 power management if the cpu enters a sleep mode that disables clocks used by the adcifa, the adcifa will stop functioning and resume operation after the system wakes up from sleep mode. before entering a sleep mode where the clock to the adcifa is stopped, make sure the analog-to-digital con- verter cell is put in an inactive state. refer to section 36.6.3 for more information. 36.5.3 clocks the clock for the adcifa bus interface (clk_adicfa) is generated by the power manager. this clock is turned on by default, and can be enabled and disabled in the power manager. it is recommended to disable the adcifa before disabling the clock, to avoid freezing the adcifa in an undefined state. 36.5.4 interrupts the adcifa interrupt line is connected to one of the internal sources of the interrupt controller (intc). using the adcifa requires the intc to be configured first. 36.5.5 event system the event controller provides th e adcifa two trigger sources. table 36-1. i/o lines description name description adcinx adc analog input adcrefp cfg.exref= 0: normal operation, this pin is used to decouple adc internal reference. adcrefp should be connected to a 1 00nf external decoupling capacitor. cfg.exref= 1: forcing reference using a dcrefp/adcrefn differential pin pair voltage please refer to the section 36.6.10 for more information. adcrefn cfg.exref= 0: normal operation, this pin is used to decouple adc internal reference. adcrefn should be connected to a 100nf external decoupling capacitor. cfg.exref= 1: forcing reference using a dcrefp/adcrefn differential pin pair voltage please refer to the section 36.6.10 for more information. adcref0 external reference input (with respect to analog ground) bypassed when cfg.rs is enabled adcref1 external reference input (with respect to analog ground) bypassed when cfg.rs is enabled vddana analog power supply gndana analog ground
1107 32117b?avr-03/11 at32uc3c 36.5.6 debug operation when an external debugger forces the cpu into debug mode: ? the adcifa continues normal operation if the bit related to adcifa in pdbg register is ?0?. pdca access continues normal operation and may interfere with debug operation. ? the adcifa is frozen if the bit related to adcifa in pdbg register is ?1?. when the adcifa is frozen, adcifa pb registers can still be acce ssed. then, reading r egisters may modify status bits (ovrx, lovrx) like in normal operation. pdca access are pending. 36.6 functional description 36.6.1 adc resolution the adc supports 8-bit, 10-bit or 12 bits resolutions. precision can be set differently for each sequencer by setting the sres bits in the seqcfgx register. by default, after a reset, the reso- lution is set to 12 bits. to get full resolution, th e user should first calibrate the adc as detailed in section 36.6.16 . 36.6.2 adc conversion modes 36.6.2.1 differential / single ended the adc is fully differential. to perform single ended measures, the user can perform pseudo unipolar conversions by connecting ground onto the negative input. user can connect it to an external ground through pads or internal ground depending on if there's one connected onto the negative input multiplexer. since conversion results are always 12 bits in 2's complement repre- sentation, the sign bit will no t change, and then th e resulting resolution is 11 bits max. 36.6.2.2 s/h versus direct conversions by default s/h are enabled, to change that setting, set the sample and hold disable bit (shd) located in the cfg register. maximum accuracy is achieved when disabling s/h but setting this bit forbids dual sequencer mode, sequencer 1 is then switched off. furthermore, in this mode s/h are switched off to lower power consumption. table 36-2. s/h versus direct conversions mode characteristics s/h pros gain setting (1, 2, 4, 8, 16, 32, 64) dual sequencer mode cons reduced accuracy dynamic limitation (fix ed with over-sampling) 1 adc clock period spent to propagate into s/h direct pros no dynamic limitation due to s/h full accuracy saves 1 adc clock period compared to the features list timings cons no gain single sequencer mode only
1108 32117b?avr-03/11 at32uc3c 36.6.3 power reduction modes configuration bits acting on the power consumpt ion of the digital and analog blocks are adc enable ( adcen) and sleep mode sele ction (sleep) bits locate d in the cfg register: depending on the start of conversion behavior (socb) bit in the sequencer configuration (seqcfgx) register, the ho t start-up sequence will be perfo rmed before each conversion or before each new conversion sequence. the adc analog block is powered off when not used, it needs 24 adc clock cycles to wake-up. if st art of conversion frequency is lower than 1/25.f(ckadc) then no conversion will be lost. 36.6.4 adc sequencer operating modes 36.6.4.1 general the adc sequencer consists in two independent 8-state sequencers (seq0 and seq1) that can also be cascaded together to form one 16-state sequencer (seq). the word ?state? repre- sents the number of auto-conversions that can be performed with the sequencer. in both cases, the adc has the ability to auto-s equence a series of conversions. this means that each time a sequencer receives a start-of-conversion request, it can perform multiple conversions automati- cally. for every sequencer conversion in dual-sequencer mode, any one of the available sequencer 16 input channels can be selected through the analog mux. in the same way, in sin- gle-sequencer mode, any of the seq0 input c hannels can be selected. after conversion, the digital value of the selected channel is stored in the appropriate result register (resn). it is also possible to sample the same channel multiple times, allowing the user to perform ?over-sam- pling?, which gives increased resolution over traditional single-sampled conversion results. 36.6.4.2 single-sequencer mode (cascaded mode) by setting the single sequencer mode (ssmq) bit in the cfg register, the two sequencers are cascaded allowing a maximum of 16 successive measures among the seq0 16 analog inputs. figure 36-2 shows a sequence of 4 differential measures, initiated by the start of conversion (soc) request. the sequence of analog inputs to be measured is determined by the values of (inpsel0x, innsel0x) and (inpse l1x, innsel1x) couples of registers. each analog input is selected by the analog multiplexer then sampled one by one every adc clock cycle. in addition, the conversion lasts (sres / 2 + 3 - shd) adc clock cycles due to the adc pipelined topology. table 36-3. power reduction mode over the adcen setting adcen behavior 0 digital controller dynamic ac tivity is stopped (gated clocks) all analog is powered off (reference sources, adc, sample & hold) 1 digital controller enabled analog references are switched on the adc block is powered on depending on the sleep bit table 36-4. power reduction mode sleep behavior 0 analog adc block always powered on 1 analog adc block powered off after each conversion
1109 32117b?avr-03/11 at32uc3c figure 36-2. single sequencer chronogram (assuming sres=8, shd=0) 36.6.4.3 dual-sequencer mode (simultaneous sampling) the adc has the ability to sample two pair s of adcinx inputs si multaneously (see figure 36-3 ), provided that one pair is from the inputs available on the sequencer 0 and the other is from the inputs available on the sequencer 1 (see figure 36-1 ). to put the adc into simultaneous sam- pling mode, the ssmq bit needs to be set in the cfg register. figure 36-3. dual sequencer chronogram (assuming sres=8, shd=0) in this chronogram, adcconv signal repres ents the value being sampled by the adc 36.6.4.4 sequencer behavior on a start of conversion thanks to the socb bit in the seqcfgx register, 2 different sequencer behaviors are possible: table 36-5. socb behavior socb comment 0 all sequence conversions are performed on a soc event. 1 a single conversion belonging to the sequence is performed on a soc event.
1110 32117b?avr-03/11 at32uc3c 36.6.4.5 sequencer start/stop mode thanks to the software acknowledge bit (sa) in the seqcfgx register, the behavior of sequencer x at the end of a sequence can be configured. the sequencer x overrun error bit (ovrx) in sr register indicates that an overrun error occurred in the sequencer x. this means that the res0 register has not been read while a new sequence is starting. events such as end-of -sequence or end-of-conversion can be caught by interrupt servicing or polling routines thanks to the seosx and seocx bits in the sr register. 36.6.4.6 sequencer free running-mode only seq0 has the free-running mode capabilit y. in free-running mode the adc continuously converts analog values configured in the sequencer. in this mode, the sequence restarts auto- matically after each end of sequence without waiting for the last conversion to finish. this mode is configured by setting the free running mode (frm) bit in the cfg register. the conversion sequence will start on the first soc defined by the trigger selection (trgsel) field in the seqcfg0 register. in this mode only seq0 is running once triggered. when converting at full speed the sequencer always wait for the last conversion to be finished to rise the sequencer end of sequence status bit (eos). figure 36-4 shows a 3 conversions sequence running. when the third channel is samp led the sequencer has to wait for the pipeline to be flushed. this takes sres/2+3-shd clock cycles. to avoid this you can run that sequence in free running mode. please refer to figure 36-5 . the sequencer will run the sequence without waiting for the pipeline to be fl ushed but the user will have to read the converted value before it is overwritten by a new conversion. figure 36-4. not using frm and converting at full speed table 36-6. sequencer start/stop mode sa comment 0 the sequencer waits for software acknowledge. acknowledge is done by writing a 1 in the seosx bit of the scr register. 1 the sequencer will restart automatically a new sequence on a new soc. results will be overwritten if not processed.
1111 32117b?avr-03/11 at32uc3c figure 36-5. using frm and converting at full speed 36.6.5 adc clock configuration (ckdiv) the clock frequency range for the adc is [1.5 mh z - 32 khz]. since the adc interface uses the system clock up to the pb maximum frequency, a clock downscale must be done if a higher fre- quency system clock is used. this scaling may also be done in order to slow down the adc conversions or increase the s/h time, without af fecting the system clock. the downscale is done by writing the maximum counter value in the counter value (cnt) field of the ckdiv register, with a possible division factor from 1 to 512 giving the following transfer function: t(ckadc)= t(ckpb) ((cnt + 1) 2). the divider is enabled as soon as the adc is enabled by setting the adcen bit in the cfg register. figure 36-6. clock generator block diagram in addition when ckdiv is written, the internal counter is reset to avoid rollover phenomena: do not write ckdiv when performing conversions. f(ckpb) should at least be 4 times greater t han f(ckadc) to make the adc controller work properly. 36.6.6 adc multiplexers settle time by default, channel multiplexers settle time is se t to half a pb clock period. if operating with a high pb clock frequency, then mux settle time can be increased to achieve a 1.5 pb clock peri- ods settle time by writ ing a one in the muxset field in the cfg register. for more information, please refer to the adc electrical characteristics. ckdiv : divide by cnt ckpb adcifa [115 khz - pb max frequency] ckadc [32 khz - 2 mhz] /2
1112 32117b?avr-03/11 at32uc3c figure 36-7. multiplexers settle time depending on the cfg. muxset configuration bit the chronogram above shows that for the same start of conversion (soc) event, ckadc rises one pb clock period later. the adc and s/h are sampling when ckadc is high, so setting the cfg.muxset bit will delay the samplin g phase by one pb clock period. 36.6.7 oversampling mode to improve conversion accuracy, it is recommended to perform oversampling. this is particu- larly useful for high impedance sources. th is mode can be used whether the adc is used in direct mode or not. please note that it behaves as if a sequence of 2 consecutive conversions had been programmed with the first conversion ignored. the consequence is a conversion rate divided by 2. also note that this mode cannot be used in conjonction with the dynamic mode. if dynamic and oversampling modes are both enabled, dynamic mode will be applied. figure 36-8. oversampling
1113 32117b?avr-03/11 at32uc3c 36.6.8 sample & hold (s/h) with gain the adc preamplifiers are made of two cascaded switched-capacitors amplifiers stages. they are used to sample analog voltages and provide it to the adc block when it has a time slot to make the conversion. it also amplifies the input voltage.
1114 32117b?avr-03/11 at32uc3c 36.6.8.1 dynamic mode dynamic mode aims at improving conversion accuracy when performing channel sweeping or measures on high frequency input signals. it is then recommended using the shdyn (sample and hold dynamic mode) bit control in the seqcfgx register. doing this causes the insertion of a supplementary sampling cycle of one ckadc clock period used to reset the sample and hold. as a consequence, conversion rate is divided by two. please note that it is useless performing oversampling when using that mode since the s/h are reseted before actually sampling. figure 36-9. sh dynamic mode 36.6.8.2 gain factor s/h allows the amplification of very small signals or buffering of very high impedance signal sources. the gain factor may be configured from 1x to 64x by writing to the sequencer conver- sion n sample and hold gain (gcnvn) field of the shgx register. the gain can be changed from sample to sample by writing the shgx registers. table 36-7. gain factor gcnvn gain 0001 0012 0104 0118 10016 10132 11064 111reserved
1115 32117b?avr-03/11 at32uc3c 36.6.9 power-up and startup time to convert correct values, both references and adc have to be powered-up correctly, otherwise wrong values will be converted until the end of the start-up time. ? cold start-up: references needs 1 ms max to establish. ? hot start-up: once references are up, 24 ckadc clock periods are needed. when in sleep mode, the hot start-up sequence is performed each time a conversion or a sequence is triggered thanks to the socb bit in the seqcfgx register. indeed, the adc analog block is powered off while not used. the end of the power-up sequence can be read from the start-up time done (sutd) bit of the sr register. this bit is set by hardware at the end of the start-up sequence and cleared by soft- ware by writing a '1' in the sutd bit of the scr register. it is also cleared by hardware when the adcifa is turned off then on by clearing an d setting the adcen bit of the cfg register. figure 36-10. power-up sequence start-up not done wait for cold start-up time start-up done adc is enabled? no done and seq request? no yes yes wait for hot start-up time done? no yes adc turned off? yes no sleep mode? yes
1116 32117b?avr-03/11 at32uc3c 36.6.10 analog reference the following sources are available as analog reference (aref) in the adc. they are selected through the reference source (rs) field in the cfg register: ? 1v internal voltage reference ? 0.6*vddana internal voltage reference ? two external reference voltage (adcref0 or adcref1 over chip analog ground) when using an internal reference, it is re commended inserting a decoupling capacitor between adcrefp and adcrefn externally (mandatory to get the full 12-bits precision). this means that two pins will be dedicated to reference decoupling. if the pins are needed for other pur- poses, the decoupling may be skipped giving a conversion accuracy of 10 bits. it is also possible to force a differential reference by settin g the cfg.exref bit. this will bypass the cfg.rs selection setting and make the ad c use the differential adcrefp/adcrefn pin pair voltage as reference. 36.6.11 conversion range the conversion amplitude range is given by the adc acquisition mode and the reference source: 36.6.12 conversion results if the half word left adjust (hwl a) bit in the seqcfgx register is set, then the result will be left adjusted on the 16 lower bits of the resn register. other wise, results will be right-adjusted. adc transfer function: all conversion results are signed in two's comple ment representation. extra bits depending on resolution and left adjust settings are padded with the sign bit. it means that if you read resn registers as a 32 bi ts register, the re sult will be correct. 36.6.13 start of conversion (soc) adc sequencers conversions can be triggered for each sequencer with the following sources: table 36-8. conversion range vs. reference reference conversion range internal reference 1 1v internal reference 2 0.6 * vddana external reference 1 min(3.5 v, vddana - 0.7) external reference 2 min(3.5 v, vddana - 0.7) resn gain v adcin p () vadcinn () () ? () () v vrefp () v vrefn () ? () -------------------------------------------------------------------------------------------------------- - 2 sres hwla 16 sres ? () + = table 36-9. trigger of start of conversion source sequencer internal timer (socx) internal timer event controller event controller re-synchronized seq0 * * * * seq1 * * * *
1117 32117b?avr-03/11 at32uc3c the sources must be configured through the trigger selection (trgsel) field of the seqcfgxregister. selecting the event controller source allows any event controller source to generate soc. the adc can serve a maximum of one soc per adc clock cycle. extra soc will be ignored and the missed start-of-conversio n (msocx) bit in the sr regist er will be set. if the soc fre- quency provided by the event cont roller exceeds the adc capabili ty, the event controller will generate an underrun status. 36.6.14 internal timer the adcifa embeds an internal timer used as a trigger source for seq0, seq1 and tsseq which can be configured by setting the itmc fields of the itimer register. internal timer trigger period= (itmc+1)*t(ckadc) the 17 bits counter allows soc period up to 174ms when ckadc clock frequency is set to 1.5 mhz. once set as a soc source, the internal timer as to be started by writing a '1' in the internal timer start (tstart) bit of the cr register. it can be stopped in the same way by writing a '1' in the tstop bit of the cr register. the current status of the internal timer can be read from the run- ning timer status (run) field of the sr register: 0 means stopped, 1 means running. in addition when the internal timer is running, if itimer register is written to change its frequency, the inter- nal counter is cleared to avoid rollover phenomena. note: it is possible to generate an internal timer event each ckadc time slot by writing 0x0 to the itimer register itmc field and by selecting the internal timer as a soc source. 36.6.15 peripheral dma there are two peripheral dma controller (pdc) channels corresponding to the maximum num- ber of sequencers that can be run at the same time. the sequencer x last converted value (lcvx) register contains the last converted value of the sequencer x according to the conversion result format. the lcv register is updated each time the sequencer ends a conversion. if the last converted value has not been read w hen a new one is available, the previous data is overwritten. this overrun status is signall ed by the sequencer x last converted value overrun (lovrx) bit in the sr register indicating that at least one overrun error occurred concerning sequencer x. the ovrx and lovrx bits of the sr register are cleared by writing a ?1? respectively in the ovrx and lovrx fields of the scr register. note: pdc transfers are 16 bits wide. 36.6.16 calibration accuracy of the conversion is based on calibration of switched capacitors and operational ampli- fiers offset cancellation. gain correction is don e by writing a calibration word into the adccal and shcal registers since it is temperature and operating voltage independent. 36.6.16.1 adc gain error calibration the adc is gain-calibrated during production, but to take advantage of this the calibration value must be read from the factory page in flash and written to the gain calibration (gcal) field of the adccal register.
1118 32117b?avr-03/11 at32uc3c 36.6.16.2 adc offset error calibration offset cancellation has to be performed by the user due to temperature and operating voltage conditions dependence. the offset can be obtained by converting a null differential value. that offset has to be negated and written into the offset calibration (ocal) field of the adccal reg- ister. then, for each conversion result, the cont roller will return the converted value added with the signed ocal value. for instance, if the offset value obtained is 0x3, then the value 0xfd must be written to ocal. please note that ocal is a 6 bits register, if the msb is high then the value will be considered negative. a saturati on mechanism avoids f lipping phenomena. ocal stores a signed number of lsb assuming the calibration has been performed in 12 bits resolu- tion. if converting at a lower resolution, correction will only take into account the appropriate most significant bits. 36.6.16.3 sample and hold gain error calibration s/h are gain-calibrated during production, but to take advantage of this the calibration value must be read from the factory page in flash and written to the sample and hold gain calibration (gain0 and gain1) fields of the shcal register. 36.6.17 window monitor there are 2 window monitors that allow to compare two of the result registers to some pre- defined threshold values. the window mode (wm) field in wcfgy register (see table 36-10 ) allows the user to configure operating mode in order to generate interrupts. the high threshold (ht) and low threshold (lt) fields in wcfgy r egister give the threshold voltage values of the comparators. the result register to monitor is selected by the source (src) field in wcfgy register. note: comparisons are performed regardless with the hwla setting (half word left adjust). 36.6.18 arbitration in dual sequencer mode, seq0 has priority over seq 1. due to the adc pipeline topology, the arbiter is implemented in order to allocate optimal time slots to each sequencer in order to pipe requests. when all analog voltages have been taken into account in the adc pipeline, an other sequencer can drive the analog blocs without waiting for the end of the whole conversion pro- cess. the adc result will be sampled by another process when getting the wanted precision. table 36-10. window modes wm modes 0 0 0 no window mode (default) 0 0 1 mode 1: active when result < ht 0 1 0 mode 2: active when result > lt 0 1 1 mode 3: active when lt < result < ht 1 0 0 mode 4: active when result >= lt or result >= ht 101reserved 110reserved 111reserved
1119 32117b?avr-03/11 at32uc3c 36.6.19 interrupts table 36-11. adcifa interrupt group line line description related status 0 sequencer 0 sequencer 0 end of sequence sequencer 0 end of conversion sequencer 0 overrun sequencer 0 (last converted value) overrun sequencer 0 missed start-of-conversion 1 sequencer 1 sequencer 1 end of sequence sequencer 1 end of conversion sequencer 1 overrun sequencer 1 (last converted value) overrun sequencer 1 missed start-of-conversion 2 start-up done start-up done 3 window window 0 window 1
1120 32117b?avr-03/11 at32uc3c 36.7 user interface note: 1. the reset values are device specific. please refer to the modue configuration section at the end of this chapter. table 36-12. adcifa register memory map offset register name access reset state 0x0000 cr register cr write-only 0x00000000 0x0004 cfg register cfg read/write 0x00000000 0x0008 sr register sr read-only 0x00000000 0x000c scr register scr write-only 0x00000000 0x0010 ssr register ssr write-only 0x00000000 0x0014 seqcfg0 register seqcfg0 read/write 0x00000000 0x0018 seqcfg1 register seqcfg1 read/write 0x00000000 0x001c shg0 register shg0 read/write 0x00000000 0x0020 shg1 register shg1 read/write 0x00000000 0x0024 inpsel00 register inpsel00 read/write 0x00000000 0x0028 inpsel01 register inpsel01 read/write 0x00000000 0x002c inpsel10 register inpsel10 read/write 0x00000000 0x0030 inpsel11 register inpsel11 read/write 0x00000000 0x0034 innsel00 register innsel00 read/write 0x00000000 0x0038 innsel01 register innsel01 read/write 0x00000000 0x003c innsel10 register innsel10 read/write 0x00000000 0x0040 innsel11 register innsel11 read/write 0x00000000 0x0044 ckdiv register ckdiv read/write 0x00000000 0x0048 itimer register itimer read/write 0x00000000 0x0058 wcfg0 register wcfg0 read/write 0x00000000 0x005c wcfg1 register wcfg1 read/write 0x00000000 0x0060 lcv0 register lcv0 read-only 0x00000000 0x0064 lcv1 register lcv1 read-only 0x00000000 0x0068 adccal register adccal read/write 0x00000000 0x006c shcal register shcal read/write 0x00000000 0x0070 ier register ier write-only 0x00000000 0x0074 idr register idr write-only 0x00000000 0x0078 imr register imr read-only 0x00000000 0x007c version register version read-only - (1) 0x0080 parameter register parameter read-only - (1) 0x0084 res register res read-only -
1121 32117b?avr-03/11 at32uc3c 36.7.1 control register name: cr access type: write-only offset: 0x00 reset value: 0x00000000 ? tstart: internal timer start bit writing a zero to this bit has no effect. writing a one to this bit starts the internal timer. this bit always reads as zero. the internal timer status can be read in the runt field of the sr register. ? tstop: internal timer stop bit writing a zero to this bit has no effect. writing a one to this bit stops the internal timer. this bit always reads as zero. the internal timer status can be read in the runt field of the sr register. ? soc1: sequencer 1 start of conversion writing a zero to this bit has no effect. writing a one to this bit makes the sequencer 1 to start a conversion. this bit always reads as zero. ? soc0: sequencer 0 start of conversion writing a zero to this bit has no effect. writing a one to this bit makes the sequencer 0 to start a conversion. this bit always reads as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - tstart tstop soc1 soc0
1122 32117b?avr-03/11 at32uc3c 36.7.2 configuration register name: cfg access type: read/write offset: 0x04 reset value: 0x00000000 ? sut: start-up time number of adc clock cycles to wait for: (startup + 1) * 32. ? muxset: mux settle time 1: the multiplexers settle time is set to 0.5 pb clock periods. 0: the multiplexers settle time is set to 1.5 pb clock periods. ? exref: external reference 1: the external forcing of references is enabled , adc references are the adcrefn and adcrefp pads. 0: the external forcing of references is disa bled, adc reference is given by the rs field. ? shd: sample-and-hold disabled 1: the sample and hold is disabled. 0: the sample and hold is enabled. note: when set to one, sequencer 1 is turned off, as a cons equence the adc pipeline latency is decreased by one adc clock period. ? rs: reference source 0: internal 1v reference. 1: internal 0.6 *vddana reference. 2: external reference adcref0 over chip analog ground. 3: external reference adcref1 over chip analog ground. ? frm: free running mode 1: the free running mode is enabled, sequencer 0 performs conversions continuously. 0: the free running modeis disabled. note: once in this mode, sequencer 1 requests cannot be serviced. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -- sut 15 14 13 12 11 10 9 8 - - - - - muxset exref - 76543210 shd rs frm ssmq sleep - adcen
1123 32117b?avr-03/11 at32uc3c ? ssmq: single sequencer mode 1: the single sequencer mode is enabled, sequencers 0 a nd 1 are merged, increasing the number of conversions per sequence. 0: the single sequencer mode is disabled, seq0 and seq1 are in simultaneous mode. ? sleep: sleep mode selection 1: the power saving mode is enabled. the analog adc block is powered off after each conversion. 0: the power saving mode is disabled. note: when enabled, start-up time is required before each new conversion. ? adcen: adc enable 1: the adc controller is enabled, the analog adc block is powered-on according to sleep mode. 0: the adc controller is disabled, the analog adc block is powered-off.
1124 32117b?avr-03/11 at32uc3c 36.7.3 status register name: sr access type: read-only offset: 0x08 reset value: 0x00000000 ? state1: sequencer 1 state register this field is set to the current conversion identifier. ? state0: sequencer 0 state register this field is set to the current conversion identifier. ? runt: running timer status this bit is set when the internal timer is started. this bit is cleared when the internal timer is stopped. ? sutd: start-up time done this bit is set when a start-up done event occurs. this bit is cleared when the corresponding bit in scr is written to one. ? msoc1: sequencer 1 missed start-of-conversion this bit is set when a start-of-conversion is missed. this bit is cleared when the corresponding bit in scr is written to one. ? msoc0: sequencer 0 missed start-of-conversion this bit is set when a start-of-conversion is missed. this bit is cleared when the corresponding bit in scr is written to one. ? wm1: window monitor 1 this bit is set when the watched result value goes to the defined window. this bit is cleared when the corresponding bit in scr is written to one. 31 30 29 28 27 26 25 24 - - - - state1 23 22 21 20 19 18 17 16 --- state0 15 14 13 12 11 10 9 8 runt sutd msoc1 msoc0 wm1 wm0 - - 76543210 lovr1 ovr1 seoc1 seos1 lovr0 ovr0 seoc0 seos0
1125 32117b?avr-03/11 at32uc3c ? wm0: window monitor 0 this bit is set when the watched result value goes to the defined window. this bit is cleared when the corresponding bit in scr is written to one. ? lovr1: sequencer 1 last converted value overrun this bit is set when an overrun error occurs on the lcv register. this bit is cleared when the corresponding bit in scr is written to one. ? ovr1: sequencer 1 overrun error this bit is set when an overrun error occurs. this bit is cleared when the corresponding bit in scr is written to one. ? seoc1: sequencer 1 end of conversion this bit is set when an end of conversion occurs. this bit is cleared when the corresponding bit in scr is written to one. ? seos1: sequencer 1 end of sequence this bit is set when an end of sequence occurs. this bit is cleared when the corresponding bit in scr is written to one. ? lovr0: sequencer 0 last converted value overrun this bit is set when an overrun error occurs on the lcv register. this bit is cleared when the corresponding bit in scr is written to one. ? ovr0: sequencer 0 overrun error this bit is set when an overrun error occurs. this bit is cleared when the corresponding bit in scr is written to one. ? seoc0: sequencer 0 end of conversion this bit is set when an end of conversion occurs. this bit is cleared when the corresponding bit in scr is written to one. ? seos0: sequencer 0 end of sequence this bit is set when an end of sequence occurs. this bit is cleared when the corresponding bit in scr is written to one.
1126 32117b?avr-03/11 at32uc3c 36.7.4 status clear register name: scr access type: write-only offset: 0x0c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register clears the corresponding bit in sr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 --- ---- 15 14 13 12 11 10 9 8 - sutd msoc1 msoc0 wm1 wm0 - - 76543210 lovr1 ovr1 seoc1 seos1 lovr0 ovr0 seoc0 seos0
1127 32117b?avr-03/11 at32uc3c 36.7.5 status set register name: ssr access type: write-only offset: 0x10 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register sets the corresponding bit in sr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 --- ---- 15 14 13 12 11 10 9 8 - sutd msoc1 msoc0 wm1 wm0 - - 76543210 lovr1 ovr1 seoc1 seos1 lovr0 ovr0 seoc0 seos0
1128 32117b?avr-03/11 at32uc3c 36.7.6 sequencer n c onfigurati on register name: seqcfgn access type: read/write offset: 0x14 + n * 0x04 reset value: 0x00000000 ? cnvnb: number of conversions in a sequence the number of conversions to perfo rm in the sequence is (cnvnb+1). ? sres: resolution 0: 12 bits. 1: 10 bits. 2: 8 bits. 3: reserved. ? trgsel: trigger selection 0: software. 1: internal adc timer. 2: event controller source. 3: continuous. ? shdyn: sample and hold dynamic mode 1: the sh dynamic mode,is enabled, a conversion takes two adc cloc k cycles, sh is reseted on the first cycle. 0: the sh dynamic mode is disabled, a conversion takes a single adc clock cycle. ? ovsx2: oversampling x2 1: the oversampling mode is enabled, a conversion takes two adc clock cycles. 0: the oversampling mode is disabled, a conversion takes a single adc clock cycle. ? socb: start of conversion behavior 1: the socb mode is enabled, a single conversion is performed on a soc event. 0: the socb mode is disabled, a comple te sequence is performed on a soc event. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - cnvnb 15 14 13 12 11 10 9 8 - - sres - - trgsel 76543210 - - - shdyn ovsx2 socb hwla sa
1129 32117b?avr-03/11 at32uc3c ? hwla: half word left adjust 1: the hwla mode is enabled. 0: the hwla mode is disabled. ? sa: software acknowledge 1: the sa mode is enabled. 0: the sa mode is disabled.
1130 32117b?avr-03/11 at32uc3c 36.7.7 sequencer n sample and hold gain for each conversion name: shgn access type: read/write offset: 0x1c+ n * 0x04 reset value: 0x00000000 ? gcnv7: sequencer n conversion 7 sample and hold gain ? gcnv6: sequencer n conversion 6 sample and hold gain ? gcnv5: sequencer n conversion 5 sample and hold gain ? gcnv4: sequencer n conversion 4 sample and hold gain ? gcnv3: sequencer n conversion 3 sample and hold gain ? gcnv2: sequencer n conversion 2 sample and hold gain ? gcnv1: sequencer n conversion 1 sample and hold gain ? gcnv0: sequencer n conversion 0 sample and hold gain 31 30 29 28 27 26 25 24 -gcnv7-gcnv6 23 22 21 20 19 18 17 16 -gcnv5-gcnv4 15 14 13 12 11 10 9 8 -gcnv3-gcnv2 76543210 -gcnv1-gcnv0
1131 32117b?avr-03/11 at32uc3c 36.7.8 sequencer n inp conversions 0 to 3 selection name: inpsel0n access type: read/write offset: 0x24+ n * 0x04 reset value: 0x00000000 ? cnv3: sequencer n inp identifier of the 4th conversion to perform ? cnv2: sequencer n inp identifier of the 3rd conversion to perform ? cnv1: sequencer n inp identifier of the 2nd conversion to perform ? cnv0: sequencer n inp identifier of the 1st conversion to perform 31 30 29 28 27 26 25 24 ---- cnv3 23 22 21 20 19 18 17 16 ---- cnv2 15 14 13 12 11 10 9 8 ---- cnv1 76543210 ---- cnv0
1132 32117b?avr-03/11 at32uc3c 36.7.9 sequencer n inp conversions 4 to 7 selection name: inpsel1n access type: read/write offset: 0x2c+ n * 0x04 reset value: 0x00000000 ? cnv7: sequencer 0 inp identifier of the 8th conversion to perform ? cnv6: sequencer 0 inp identifier of the 7th conversion to perform ? cnv5: sequencer 0 inp identifier of the 6th conversion to perform ? cnv4: sequencer 0 inp identifier of the 5th conversion to perform 31 30 29 28 27 26 25 24 ---- cnv7 23 22 21 20 19 18 17 16 ---- cnv6 15 14 13 12 11 10 9 8 ---- cnv5 76543210 ---- cnv4
1133 32117b?avr-03/11 at32uc3c 36.7.10 sequencer n inn conversions 0 to 3 selection name: innsel0n access type: read/write offset: 0x34+ n * 0x04 reset value: 0x00000000 ? cnv3: sequencer n inn identifier of the 4th conversion to perform ? cnv2: sequencer n inn identifier of the 3rd conversion to perform ? cnv1: sequencer n inn identifier of the 2nd conversion to perform ? cnv0: sequencer n inn identifier of the 1st conversion to perform 31 30 29 28 27 26 25 24 ---- cnv3 23 22 21 20 19 18 17 16 ---- cnv2 15 14 13 12 11 10 9 8 ---- cnv1 76543210 ---- cnv0
1134 32117b?avr-03/11 at32uc3c 36.7.11 sequencer n inn conversions 4 to 7 selection name: innsel1n access type: read/write offset: 0x3c+ n * 0x04 reset value: 0x00000000 ? cnv7: sequencer n inn identifier of the 8th conversion to perform ? cnv6: sequencer n inn identifier of the 7th conversion to perform ? cnv5: sequencer n inn identifier of the 6th conversion to perform ? cnv4: sequencer n inn identifier of the 5th conversion to perform 31 30 29 28 27 26 25 24 ---- cnv7 23 22 21 20 19 18 17 16 ---- cnv6 15 14 13 12 11 10 9 8 ---- cnv5 76543210 ---- cnv4
1135 32117b?avr-03/11 at32uc3c 36.7.12 clock divider register name: ckdiv access type: read/write offset: 0x44 reset value: 0x00000000 ? cnt: max counter value number of adc clock cycles to count: (cnt + 1) * 2. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------cnt[8] 76543210 cnt[7:0]
1136 32117b?avr-03/11 at32uc3c 36.7.13 internal timer register name: itimer access type: read/write offset: 0x48 reset value: 0x00000000 ? itmc: internal timer max counter number of adc clock cycles to wait for is (itmc + 1). note: this allows soc period up to 167 ms when ckadc clock is running at 1.5 mhz. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------itmc[16] 15 14 13 12 11 10 9 8 itmc[15:8] 76543210 itmc[7:0]
1137 32117b?avr-03/11 at32uc3c 36.7.14 window monitor n configuration register name: wcfgn access type: read/write offset: 0x58+ n * 0x04 reset value: 0x00000000 ?src: index of the result register to monitor (0 to 16). ? wm: window mode 0: no window mode. 1: mode 1: res(src) < ht. 2: mode 2: res(src) > lt. 3: mode 3: lt< res(src) < ht. 4: mode 4: (lt >= res(src)) || (res(src) >= ht). 5: reserved. 6: reserved. 7: reserved. ? ht: high threshold ? lt: low threshold 31 30 29 28 27 26 25 24 -src wm 23 22 21 20 19 18 17 16 ht[11:4] 15 14 13 12 11 10 9 8 ht[3:0] lt[11:8] 76543210 lt[7:0]
1138 32117b?avr-03/11 at32uc3c 36.7.15 sequencer n last converted value name: lcvn access type: read-only offset: 0x60+ n * 0x04 reset value: 0x00000000 ? lcv: last converted value this field is set by hardware to the last sequencer converted value. depending on precision, the higher bits are padded with th e sign bit. 31 30 29 28 27 26 25 24 lcv[31:24] 23 22 21 20 19 18 17 16 lcv[23:16] 15 14 13 12 11 10 9 8 lcv[15:8] 76543210 lcv[7:0]
1139 32117b?avr-03/11 at32uc3c 36.7.16 adc calibration register name: adccal access type: read/write offset: 0x68 reset value: 0x00000000 ? ocal: offset calibration ? gcal: gain calibration 31 30 29 28 27 26 25 24 -ocal 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - gcal[14:8] 76543210 gcal[7:0]
1140 32117b?avr-03/11 at32uc3c 36.7.17 sh calibration register name: shcal access type: read/write offset: 0x6c reset value: 0x00000000 ? gain1: sample and hold 1 gain calibration ? gain0: sample and hold 0 gain calibration 31 30 29 28 27 26 25 24 - - - - - gain1[9:8] 23 22 21 20 19 18 17 16 gain1[7:0] 15 14 13 12 11 10 9 8 -- gain0[9:8] 76543210 gain0[7:0]
1141 32117b?avr-03/11 at32uc3c 36.7.18 interrupt enable register name: ier access type: write-only offset: 0x70 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 --- ---- 15 14 13 12 11 10 9 8 - sutd msoc1 msoc0 wm1 wm0 - - 76543210 lovr1 ovr1 seoc1 seos1 lovr0 ovr0 seoc0 seos0
1142 32117b?avr-03/11 at32uc3c 36.7.19 interrupt disable register name: idr access type: write-only offset: 0x74 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 --- ---- 15 14 13 12 11 10 9 8 - sutd msoc1 msoc0 wm1 wm0 - - 76543210 lovr1 ovr1 seoc1 seos1 lovr0 ovr0 seoc0 seos0
1143 32117b?avr-03/11 at32uc3c 36.7.20 interrupt mask register name: imr access type: read-only offset: 0x78 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 --- ---- 15 14 13 12 11 10 9 8 - sutd msoc1 msoc0 wm1 wm0 - - 76543210 lovr1 ovr1 seoc1 seos1 lovr0 ovr0 seoc0 seos0
1144 32117b?avr-03/11 at32uc3c 36.7.21 version register name: version access type: read-only offset: 0x7c reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
1145 32117b?avr-03/11 at32uc3c 36.7.22 parameter register name: parameter access type: read-only offset: 0x80 reset value: 0x00000000 ? n: number of channels ? m: number of states per sequencer 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 n 76543210 m
1146 32117b?avr-03/11 at32uc3c 36.7.23 result register name: resn access type: read-only offset: 0x84+ n * 0x04 reset value: 0x00000000 ? res: result register contains value of conversion n. 31 30 29 28 27 26 25 24 res[31:24] 23 22 21 20 19 18 17 16 res[23:16] 15 14 13 12 11 10 9 8 res[15:8] 76543210 res[7:0]
1147 32117b?avr-03/11 at32uc3c 36.8 module configuration the specific configuratio n for each adc instance is listed in the following tables. the module bus clocks listed here are connected to the system bus clocks according to the table in the sys- tem bus clock connections section. the differential inputs of the adc are configured through the following registers of the adcifa: ? inpsel00, inpsel01, innsel00 and innsel01 for t he sequencer 0 ? inpsel10, inpsel11, innsel10 and innsel11 for t he sequencer 1 the configuration allows to se lect pin or internal voltage. the adc voltage reference can be selected as external reference through the rs register of the adcifa. for detail, see th e adcifa chapter. table 36-13. module configuration feature adcifa nbconv 8 table 36-14. module clock name module name clock name description adcifa clk_adcifa peripheral bus clock from the pbc clock domain table 36-15. register reset values register reset value version 0x00000110 parameter 0x00000808
1148 32117b?avr-03/11 at32uc3c the following table defines the va lid settings for the conv fi eld of the inpselxy and innselxy registers in the adcifa. this setting defi nes the mapping of the adc input voltage. table 36-16. inp0/1 selection inpsel00[convi], inpsel10[convi], inpsel01[convi], inpsel11[convi] n ame connection 0 adcin0 see peripheral multiplexing on i/o line chapter 1 adcin1 2 adcin2 3 adcin3 4 adcin4 5 adcin5 6 adcin6 7 adcin7 8 dac0_int internal output of the dac0 10 gndana analog ground table 36-17. inn0/1 selection innsel00[convi], innsel10[convi], innsel01[convi], innsel11[convi] n ame connection 0 adcin8 see peripheral multiplexing on i/o line chapter 1 adcin9 2 adcin10 3 adcin11 4 adcin12 5 adcin13 6 adcin14 7 adcin15 8 dac1_int internal output of the dac1 9 gndana analog ground table 36-18. external reference selection rs name connection 0 internal 1v reference 1 internal 0.6*vddana reference 2 adcref0 see peripheral multiplexing on i/o line chapter 3 adcref1
1149 32117b?avr-03/11 at32uc3c 37. dacifb interface (dacifb) rev.: 1.1.0.1 37.1 features ? 12-bit resolution ? flexible conversion range ? 1 continuous time or 2 sample/hold (s/h) outputs ? multiple trigger sources for each channel ? built-in offset an d gain calibration ? can be used as input to analog comparator or adc (as an intern al wire and without s/h stage) ? two pdca channels ? low-power mode 37.2 overview the dac interface (dacifb) controls a dac that converts digital values to analog voltages with 12-bit resolution. the output from the dac can either be continuous to one pin, or fed to two dif- ferent pins using a sample and hold circuitry. options like low power mode and gain and offset calibration are available. the output signal swing is defined by the refe rence voltage aref. the dac operates in unipo- lar mode, i.e. output voltage shifts within the 0v to aref range. the following sources are available as aref reference voltage: ?vddana ? an external reference applied to the dacref input pin.
1150 32117b?avr-03/11 at32uc3c 37.3 block diagram figure 37-1. dacifb block diagram analog dac dac interface (dacifb) data channel a data channel b dac channel a s/h output dac channel b s/h output dac ctrl data alignment dac output control and driver (s/h) channel b trigger mux enable a/b select data alignment 16 bits 16 bits trig select b p b i/o controller trig select a arbiter dac calibration ctrl gain calibration offset calibration ch b 12 bits ch a 12 bits p d c a timer channel a timer channel b channel a trigger mux peripheral event controller (pevc) i n t c o n t r o l prescaler ch a data empty internal output to analog comparator or adc ch b data empty ch a data underrun ch b data underrun ch a data overrun ch b data overrun
1151 32117b?avr-03/11 at32uc3c 37.4 i/o lines description 37.5 product dependencies 37.5.1 i/o lines the pins used for interfacing the dac may be multiplexed with gpio lines. the programmer must first program the gpio controller to assign the desired dac pins to their peripheral func- tion. if i/o lines of the dac are not used by the application, they can be used for other purposes by the gpio controller. 37.5.2 power management if the cpu enters a sleep mode that disables clk_dacifb used by the dacifb, the dacifb will stop functioning and will resu me operation after the system wakes up from sleep mode. 37.5.3 clocks the dacifb is clocked through the power manager (pm), therefore the programmer must first configure the pm to enable the clk_dacifb clock. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to disable the dacifb before disabling the clock, to avoid freezing the dacifb in an undefined state. 37.5.4 interrupts the dacifb interrupt lines are connected to the internal sources of the interrupt controller. using the dacifb interrupts requires the interrupt controller to be programmed first. 37.5.5 peripheral events the dacifb peripheral events are connected via the peripheral event controller. refer to the peripheral event controller chapter for details. 37.5.6 debug operation the dacifb is disabled during debug operation, unless the run in debug bit in the develop- ment control register is set and the bit corresponding to the dacifb is set in the peripheral debug register (pdbg). please refer to the on-chip debug chapter in the avr32uc technical reference manual, and the ocd module configuration section, for details. the dacifb is debug-mode aware. when the cpu is in debug mode, all the incoming triggers are blocked, therefore all dma based conversions are halted upon debug mode activation. the auto-refresh functionality is kept active so that the last converted value remains visible on both channels outputs. apart from the auto-trig mode, it is possible to perform ?one shot? conversions triggered by write accesses to the data register. table 37-1. i/o lines description pin name pin description type active level daca dac channel a analog output output n/a dacb dac channel b analog output output n/a dacref dac voltage reference input n/a
1152 32117b?avr-03/11 at32uc3c 37.6 functional description 37.6.1 basic operation 37.6.1.1 output channels the output from the dac can either be conti nuous to one pin (dac c hannel a only), or fed to two different pins using a sample and hold circ uitry (s/h). with s/h these two outputs can act independently and create two different analog signals, different in both voltage and frequency. the two s/h outputs have individual data and conversion control registers. the dac output may be used as internal input signal to other peripherals, such as the analog comparator or the adc. only the dac internal output can be used as internal input, the s/h out- puts can not be used as such. note that in this internal routing mode, both s/h modules must be deactivated in order to avoid dist urbances on the internal channel. 37.6.1.2 timing constraints some timing constraints must be observed in order to make sure the s/h circuitry operates cor- rectly. these are relative to the frequency of the peripheral clock of the dacifb, as this will affect the charging/discharging periods of the s/h circuitry. not meeting these constraints will result in reducing the accuracy of the dac conversions. the dac sampling time is the time interval between two conversions. without s/h operating, this figure should be equal or greater than the dac minimum sampling period (corresponding to the dac maximum sampling frequency). with s/h operating, this figure should be equal or greater than 1.5 times the dac minimum sampling period. when the sampling frequency is too low, the s/h circuitry may let the output voltage drop signif- icantly between two consecutive conversi ons. if enabled, the auto-refresh mode will automatically repeat continuously the conversion of the last channel data . this allows maintain- ing the voltage level on the s/h outputs, whenever the time elapsed between two data to be converted is too long. the dac refresh time is the time interval between two channel data updates, it can not be smaller than the minimum sampling period. the analog dac startup time is non-null, therefore a waiting period of a few clk_dacifb clock cycles must be observed before consid ering conversion of the first data. note that if s/h is enabled, t he actual sampling period will be 1. 5 times greater than the pro- grammed sampling period. 37.6.1.3 starting a conversion conversions are either performed upon writes to the data registers or triggered by an incoming event (auto-trig mode). both application software and the peripheral dma controller may write to the data registers. using the peripheral dma controller to write data to the dacifb, together with an event input to trigger conversions, gives the most accurate timing for conversions. the peripheral dma controller data transfer rate depends on the sampling frequency imposed by the event line. the dacifb sends a request to the peripheral dma controller, and once the request is granted (peripheral dma controller acknowledge) the conversion is performed upon reception of a trigger event.
1153 32117b?avr-03/11 at32uc3c 37.6.1.4 data registers data to be converted is taken from two register s, one for each channel: data register 0 (dr0) for channel a and data register 1 (dr1) for channel b. alternatively both samples to be converted can be written to dr0 in a single write cycle, in this configuration the values for channel b and a are written to the upper and the lower half words of dr0, respectively. this operation is possible only if the dac dual data in data register a bit of the configuration register (cfr.dda) is enabled. while the field reserved for the data to be convert ed is 16 bits wide, only the 12 lower bits are considered for conversion. in order to match the expected data alignment, rounded right and left shifts are programmable within a separate register for each data channel. 37.6.2 advanced operation 37.6.2.1 prescaler a programmable prescaler generates a divided cloc k signal from the system clock. this signal is then fed to the following dacifb programmable counters, as shown on figure 37-2 : ? the channel interval counter, which sets the mi nimum time interval between two samples, or in other words, the maximum sampling frequency (see chi bitfield in the tcr register). ? the s/h refresh counter which, in refresh mode, counts a defined number of prescaled clock ticks (corresponding to the refresh time) before repeating the conversion of the last received data (see chra and chrb bitfields in the tcr register). ? trigger event timer counters for both channels which, in timer trigged mode, count a defined number of prescaled clock ticks before triggering a conversion (see the tra and trb registers). the limitations described in the ?timing constraints? paragraph must be taken into consideration when configuring these programmable counters. in addition to these constraints, when both channels are in use with auto-refresh mode enabled, the refresh rate should not be significantly higher than the sampling rate on the other channel as this might cause unexpected behavior on the latter channel.
1154 32117b?avr-03/11 at32uc3c figure 37-2. dac timing counters 37.6.2.2 low power mode in order to reduce the power consumption dur ing dac conversions, the dac low power mode may be enabled. in low power mode, the dac is turned off between each conversion. conversion time will be longer if new conversions are st arted in this mode: a fourfold increase of the dac?s output settling time should be expected. 37.6.2.3 calibration to achieve optimal accuracy, it is possible to calibrate both gain (goc.gcr) and offset error (goc.ocr) in the dac. gain and offset are not calibrated automatically and this must be done by software. to perform this operation, the dac internal output must be beforehand routed to the adc using the cr.ie bit. the test values converted by the dac are sampled by the adc which returns a measured value of the dac output. calculating the difference between a series of dacifb channel input values and their respective effective levels after conversion makes it possible to deduce both dac gain and offset biases. to get the best calibration result, it is recommended to use the same aref voltage, output channel selection, sampling time, and refresh interval when calibrating as in normal dac operation. including errors, the dac output value can be expressed as: prescaler tcr.presc[2:0] channel interval counter tcr.chi[6:0] refresh counter tcr.chra[3:0] refresh counter tcr.chrb[3:0] timing counter tra.tcd[7:0] timing counter trb.tcd[7:0] prescalerclock clk_dacifb
1155 32117b?avr-03/11 at32uc3c v dacxx = gain x (data chx / 0xfff) + offset in an ideal dac, gain is 1 and offset 0. 37.6.3 interrupts an interrupt request will be generated if the corresponding bit in the interrupt mask register (imr) is set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier), and cleared by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt request remains acti ve until the corresponding bit in sr is cleared by writing a one to the corresponding bit in the status clear register (scr). after processing a channel input data, if the data input buffer is empty, the dacifb signals a data empty interrupt to the interrupt controller. an underrun interrupt will be gene rated if two consecutive trigge r events are issued without any new channel data being fed to the dacifb in the meantime. an overrun interrupt will be gener ated if an additional channel data is sent to the dacifb while the input buffer is already full. 37.6.4 peripheral events channel conversions can be triggered by an independent event source. a simple arbiter priori- tizes trigger event requests if the two channels are activated at the same time. trigger events for both channels are taken either from the pevc input or from the dacifb inter- nal trigger timers. these two timers are set up separately and both use prescalerclock as their reference clock (see the tra and trb registers).
1156 32117b?avr-03/11 at32uc3c 37.7 user interface table 37-2. dacifb register memory map offset register register name access reset 0x00 control register cr read/write 0x00000000 0x04 configuration register cfr read/write 0x00000000 0x08 event input control register ecr read/write 0x00000000 0x0c timing control register tcr read/write 0x00000000 0x10 interrupt enable register ier write-only - 0x14 interrupt disable register idr write-only - 0x18 interrupt mask register imr read-only 0x00000000 0x1c status register sr read-only 0x00000000 0x20 status clear register scr write-only - 0x24 data register control channel a drca read/write 0x00000001 0x28 data register control channel b drcb read/write 0x00000001 0x2c data register 0 dr0 read/write 0x00000000 0x30 data register 1 dr1 read/write 0x00000000 0x34 gain and offset calibration register goc read/write 0x00000000 0x38 timer register channel a tra read/write 0x00000000 0x3c timer register channel b trb read/write 0x00000000 0x40 version register version read-only - (1) 1. the reset value for this register is device specific. please refer to the module configuration section at the end of this cha pter.
1157 32117b?avr-03/11 at32uc3c 37.7.1 control register name: cr access type: read/write offset: 0x00 reset value: 0x00000000 ? arbe: dac auto refresh channel b enable 0: auto-refresh on channel b is disabled. 1: auto-refresh on channel b is enabled. ? arae: dac auto refresh channel a enable 0: auto-refresh on channel a is disabled. 1: auto-refresh on channel a is enabled. ? trbe: dac timer register channel b enable 0: the timer generating a clocked trigger on channel b is disabled. 1: the timer generating a clocked trigger on channel b is enabled. ? trae: dac timer register channel a enable 0: the timer generating a clocked trigger on channel a is disabled. 1: the timer generating a clocked trigger on channel a is enabled. ? boe: dac channel b output enable 0: channel b analog output is disabled. 1: channel b analog output is enabled. ? aoe: dac channel a output enable 0: channel a analog output is disabled. 1: channel a analog output is enabled. ? en: dac enable 0: dac is disabled. 1: dac is enabled. 31 30 29 28 27 26 25 24 - - - - arbe arae trbe trae 23 22 21 20 19 18 17 16 ------boeaoe 15 14 13 12 11 10 9 8 -------- 76543210 -------en
1158 32117b?avr-03/11 at32uc3c 37.7.2 configuration register name: cfr access type: read/write offset: 0x04 reset value: 0x00000000 ? chc: dac channel configuration these bits control whether the dac should operat e with sample and hold on outputs or not. ? abe: dac auto triggered mode enable channel b 0: the conversion is triggered by the data register write access. 1: the incoming event (from the event line select ed in the ecr register) triggers the conversion. ? aae: dac auto triggered mode enable channel a 0: the conversion is triggered by the data register write access. 1: the incoming event (from the event line select ed in the ecr register) triggers the conversion. ? ref: dac reference selection this bit controls the voltage reference selection and therefore the output voltage range of the dac. 31 30 29 28 27 26 25 24 ------ chc 23 22 21 20 19 18 17 16 - - - - - - abe aae 15 14 13 12 11 10 9 8 -------ref 76543210 -----dseddalp chc description 00 s/h modules on both channels are deactivated. internal routing only. 01 single channel operation: conversions on channel a only (s/h module activated). 10 single channel operation: conversions on channel b only (s/h module activated). 11 dual channel operation: conversions on both channels with both s/h modules activated. ref voltage reference selection 0 external reference (vref+ pin) 1vddana
1159 32117b?avr-03/11 at32uc3c ? dse: dac data setup extra clock cycle 0: no extra clock latency. 1: add an extra clock cycle latency between data written and start of conversion. th is may be useful wh en the dac clock is running fast. adding an extra cloc k cycle latency might help meeting the data setup ti me constraint. ? dda: dac dual data in data register a 0:no dual data in dr0. 1:dual data in dr0. this allows writing two 16-bit wide data words in a single write operation to the dr0 register. in this cas e the 16 upper bits are assigned to the channel b data word while the lower 16 bits remain assigned to the channel a data word. ? lp: dac low power reduction mode 0: dac low power mode disabled. 1: dac low power mode enabled.
1160 32117b?avr-03/11 at32uc3c 37.7.3 event input control register name: ecr access type: read/write offset: 0x08 reset value: 0x00000000 ? eslb: dac event input selection channel b 0: the channel b trigger timer is used 1: the peripheral event controller input is used ? esla: dac event input selection channel a 0: the channel a trigger timer is used 1: the peripheral event controller input is used 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------eslb 76543210 -------esla
1161 32117b?avr-03/11 at32uc3c 37.7.4 timing control register name: tcr access type: read/write offset: 0x0c reset value: 0x00000000 ? presc: dac timer prescaler the prescaling ratio between prescalerclock and clk_dacifb. ? chi: dac channel interval control number of prescalerclock ticks counted as the minimum time gap between two consecutive conversions . this should not be lower than the minimum sampling period. 31 30 29 28 27 26 25 24 ----- presc 23 22 21 20 19 18 17 16 - chi 15 14 13 12 11 10 9 8 ---- chrb 76543210 ---- chra presc description 000 clk_dacifb / 1 001 clk_dacifb / 2 010 clk_dacifb / 4 011 clk_dacifb / 8 100 clk_dacifb / 16 101 clk_dacifb / 32 110 clk_dacifb / 64 111 clk_dacifb / 128
1162 32117b?avr-03/11 at32uc3c ? chrn : dac channel refresh timing control channel n the time interval between each channel output refresh. this in terval avoids losing accuracy of the converted value between two consecutive conversions when the sampling rate is low. chrn description 0000 prescalerclock / 2 0001 prescalerclock / 4 0010 prescalerclock / 8 0011 prescalerclock / 16 0100 prescalerclock / 32 0101 prescalerclock / 64 0110 prescalerclock / 128 0111 prescalerclock / 256 1000 prescalerclock / 512 1001 prescalerclock / 1024 others reserved
1163 32117b?avr-03/11 at32uc3c 37.7.5 interrupt enable register name: ier access type: write-only offset: 0x10 reset value: - writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- --debdea 15 14 13 12 11 10 9 8 ------uaua 76543210 ------oboa
1164 32117b?avr-03/11 at32uc3c 37.7.6 interrupt disable register name: idr access type: write-only offset: 0x14 reset value: - writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- --debdea 15 14 13 12 11 10 9 8 ------ubua 76543210 ------oboa
1165 32117b?avr-03/11 at32uc3c 37.7.7 interrupt mask register name: imr access type: read-only offset: 0x18 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- --debdea 15 14 13 12 11 10 9 8 ------ubua 76543210 ------oboa
1166 32117b?avr-03/11 at32uc3c 37.7.8 status register name: sr access type: read-only offset: 0x1c reset value: 0x00000000 ? deb: dac data register empty channel b flag 0: data register not empty, writing to the dat a register may cause losing a conversion value. 1: data register for channel b is empty, mean ing that a new channel input data may be written. ? dea: dac data register empty channel a flag 0: data register not empty, writing to the dat a register may cause losing a conversion value. 1: data register for channel a is empty, mean ing that a new channel input data may be written. ? ub: dac underrun interrupt channel b flag 0: no underrun in channel b has occurred. 1: underrun has occurred, at least two consecutive trigger events were received without any new incoming data on channel b in the meantime. ? ua: dac underrun interrupt channel a flag 0: no underrun in channel a has occurred. 1: underrun has occurred, at least two consecutive trigger events were received without any new incoming data on channel a in the meantime. ? ob: dac overrun interrupt channel b flag 0: no overrun in channel b has occurred. 1: overrun has occurred, a new input data was received on channel b while the input buffer was already full. ? oa: dac overrun interrupt channel a flag 0: no overrun in channel a has occurred. 1: overrun has occurred, a new input data was received on channel a while the input buffer was already full. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- --debdea 15 14 13 12 11 10 9 8 ------ubua 76543210 ------oboa
1167 32117b?avr-03/11 at32uc3c 37.7.9 status clear register name: scr access type: write-only offset: 0x20 reset value: 0x00000000 writing a bit to one will clear the corresponding bit in isr. writing a bit to zero has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- --debdea 15 14 13 12 11 10 9 8 ------ubua 76543210 ------oboa
1168 32117b?avr-03/11 at32uc3c 37.7.10 data register control channel a name: drca access type: read/write offset: 0x24 reset value: 0x00000001 ? dsd: dac data shift direction 0: dac input value to be converted is right aligned 1: dac input value to be converted is left aligned. ? dsv: dac data shift value the number of left or ri ght shifts to be performed on the 16-bit s data word before being fed to the dac. up to 4 left shifts and 4 right shifts ar e possible. set bit 3 to obtain a left shif t, leave it de-asserted to perform a right shift. ? drn: dac data rounding enable 0: no rounding 1: rounding with right shifting is enabled. this adds "1" to the lsb before the last right shift. this feature is enabled by de fault. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----dsd dsv 76543210 -------drn
1169 32117b?avr-03/11 at32uc3c 37.7.11 data register control channel b name: drcb access type: read/write offset: 0x28 reset value: 0x00000001 ? dsd: dac data shift direction 0: dac input value to be converted is right aligned 1: dac input value to be converted is left aligned. ? dsv: dac data shift value the number of left or ri ght shifts to be performed on the 16-bit s data word before being fed to the dac. up to 4 left shifts and 4 right shifts ar e possible. set bit 3 to obtain a left shif t, leave it de-asserted to perform a right shift. ? drn: dac data rounding enable 0: no rounding 1: rounding with right shifting is enabled. this adds "1" to th e lsb before the last right shif t. this feature is enabled by de fault. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----dsd dsv 76543210 -------drn
1170 32117b?avr-03/11 at32uc3c 37.7.12 data register channel 0 name: dr0 access type: read/write offset: 0x2c reset value: 0x00000000 ? dcb: dac data channel b the right-aligned 12-bit value to be converted on channel b, when the dda bit within the cfr register is activated. this allows conversions on both channels in a single register write cycle. when dda is deactivated this field is ignored, and the data to b e converted on channel b should then be written to the dr1 register. ? dca: dac data channel a the right-aligned 12-bit value to be converted on channel a. 31 30 29 28 27 26 25 24 dcb 23 22 21 20 19 18 17 16 dcb 15 14 13 12 11 10 9 8 dca 76543210 dca
1171 32117b?avr-03/11 at32uc3c 37.7.13 data register channel 1 name: dr1 access type: read/write offset: 0x30 reset value: 0x00000000 ? dcb: dac data channel b the right-aligned 12-bit value to be converted on channel b. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 dcb 76543210 dcb
1172 32117b?avr-03/11 at32uc3c 37.7.14 gain and offset calibration register name: goc access type: read/write offset: 0x34 reset value: 0x00000000 ? gcr: dac gain calibration value these bits are used to compensate the gain error in the dac. note that the size of the gcr field can change depending of implementation. see the m odule configuration section. ? ocr: dac offset calibration value these bits are used to compensat e the offset error in the dac. note that the size of the ocr field can change depending of implementation. see the m odule configuration section. 31 30 29 28 27 26 25 24 gcr 23 22 21 20 19 18 17 16 gcr 15 14 13 12 11 10 9 8 ocr 76543210 ocr
1173 32117b?avr-03/11 at32uc3c 37.7.15 timer register channel a name: tra access type: read/write offset: 0x38 reset value: 0x00000000 ? trl: dac timer reload write this bit to one to re-initialize the counter. ? tcd: dac timer count down value these bits are used to program the timing counter countdown value. the timer counts from this value down to zero and then issues a trigger signal before reloading the count register. 31 30 29 28 27 26 25 24 trl------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 tcd
1174 32117b?avr-03/11 at32uc3c 37.7.16 timer register channel b name: trb access type: read/write offset: 0x3c reset value: 0x00000000 ? trl: dac timer reload write this bit to one to re-initialize the counter. ? tcd: dac timer count down value these bits are used to program the timing counter countdown value. the timer counts from this value down to zero and then issues a trigger signal before reloading the count register. 31 30 29 28 27 26 25 24 trl------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 tcd
1175 32117b?avr-03/11 at32uc3c 37.7.17 version register name: version access type: read-only offset: 0x40 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version 76543210 version
1176 32117b?avr-03/11 at32uc3c 37.8 module configuration the specific configuration for ea ch dacifb instance is listed in the following tables. the module bus clocks listed here are connected to the syst em bus clocks. please refer to the power man- ager chapter for details. table 37-3. dacifb configuration feature dacifb0 dacifb1 goc.gcr size 8-bit 8-bit goc.ocr size 9-bit 9-bit table 37-4. dacifb clock name module name clock name description dacifb0 clk_dacifb0 peripheral bus clock from the pba clock domain dacifb1 clk_dacifb1 peripheral bus clock from the pba clock domain table 37-5. register reset values register reset value version 0x00000110
1177 32117b?avr-03/11 at32uc3c 38. awire uart (aw) rev: 2.3.0.0 38.1 features ? asynchronous receiver or transmitter when the awire system is not used for debugging. ? one- or two-pin operation supported. 38.2 overview if the aw is not used for debugging, the awire ua rt can be used by the user to send or receive data with one start bit, eight data bits, no parit y bits, and one stop bit. this can be controlled through the awire uart user interface. this chapter only describes the awire uart user interface. for a description of the awire debug interface, please see the programming and debugging chapter. 38.3 block diagram figure 38-1. awire debug interface block diagram uart reset filter external reset aw_enable reset_n baudrate detector rw sz addr data crc aw control aw user interface sab interface reset command power manager cpu halt command flash controller chip_erase command awire debug interface pb sab
1178 32117b?avr-03/11 at32uc3c 38.4 i/o lines description 38.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 38.5.1 i/o lines the pin used by aw is multiple xed with the reset_n pi n. the reset function ality is the default function of this pin. to enable the awire func tionality on the reset_n pin the user must enable the awire uart user interface. 38.5.2 power management if the cpu enters a sleep mode that disables clocks used by the awire uart user interface, the awire uart user interface will stop functioning and resume operation af ter the system wakes up from sleep mode. 38.5.3 clocks the awire uart uses the internal 120 mhz rc oscillator (rc120m) as clock source for its operation. when using the awire uart user interface rc120m must enabled using the clock request register (see section 38.6.1 ). the clock for the awire uart user interface (clk_aw) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to disable the awire uart user interface before di sabling the clock, to avoid freezing the awire uart user interface in an undefined state. 38.5.4 interrupts the awire uart user interface interrupt request line is connected to the interrupt controller. using the awire uart user interface interrupt requires the interrupt controller to be pro- grammed first. 38.5.5 debug operation if the aw is used for debug ging the awire uart user interface will not be usable. when an external debugger forces the cpu into debug mode, the awire uart user interface continues normal operation. if the awire uart user interface is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper opera- tion or data loss may result during debugging. 38.6 functional description the awire uart user interface can be used as a spare asynchronous receiver or transmitter when aw is not used for debugging. table 38-1. i/o lines description name description type data awire data multiplexed wit h the reset_n pin. input/output
1179 32117b?avr-03/11 at32uc3c 38.6.1 how to initialize the module to initialize the awire uart user interface the user must first enable the clock by writing a one to the clock enable bit in the clock request r egister (clkr.clken) and wait for the clock enable bit in the status register (sr.cenabl ed) to be set. after doing this either receive, transmit or receive with resync must be selected by writing th e corresponding value into the mode field of the control (ctrl.mode) register. due to the rc120m being asynchronous with the system clock values must be allowed to propagate in the syst em. during this time the awire master will set the busy bit in the status register (sr.busy). after the sr.busy bit is cleared the baud rate field in the baud rate register (brr.br) can be written with the wanted baudrate ( ) according to the following formula ( is the rc120m clock frequency): after this operation the user must wait until the sr.busy is clea red. the interface is now ready to be used. 38.6.2 basic asynchronous receiver operation the awire uart user interface must be initialized according to the sequence above, but the ctrl.mode field must be written to one (receive mode). when a data byte arrives the awire uart user interface will indicate this by setting the data ready interrupt bit in the status register (sr.dreadyint). the user must read the data in the receive holding register (rhr.rxdata) and clear the interrupt bit by writing a one to the data ready interrupt clear bit in the status clear register (scr.dreadyint). the interface is now ready to receive another byte. 38.6.3 basic asynchronous transmitter operation the awire uart user interface must be initialized according to the sequence above, but the ctrl.mode field must be written to two (transmit mode). to transmit a data byte the user must write the data to the transmit holding register (the.txdata). before the next byte can be written the sr.busy must be cleared. 38.6.4 basic asynchronous receiver with resynchronization by writing three into ctrl.mode the awire uart user interface will assume that the first byte it receives is a sync byte (0x55) and set brr. br according to this. all subsequent transfers will assume this baudrate, unless brr.br is rewritten by the user. to make the awire uart user interface accept a new sync resynchronization the awire uart user interface must be disabled by writing zero to ctrl.mode and then reenable the interface. 38.6.5 overrun in receive mode an overrun can occur if the user has not read the previous received data from the rhr.rxdata when the newest data should be pl aced there. such a condition is flagged by setting the overrun bit in the status register (sr.overrun). if sr.overrun is set the new- est data received is placed in rhr.rxdata and the data that was there before is overwritten. f br f aw f br 8 f aw br ----------- =
1180 32117b?avr-03/11 at32uc3c 38.6.6 interrupts to make the cpu able to do other things while wa iting for the awire uart user interface to fin- ish its operations the awire uart user interface supports generating interrupts. all status bits in the status register can be used as interrupt sources, except the sr.busy and sr.cenabled bits. to enable an interrupt the user must write a one to the corresponding bit in the interrupt enable register (ier). upon the next zero to one transition of this sr bit the awire uart user interface will flag this interrupt to the cpu. to clear the interrupt the user must write a one to the corre- sponding bit in the status clear register (scr). interrupts can be disabled by writing a one to th e corresponding bit in the interrupt disable reg- ister (idr). the interrupt mask register (imr) can be read to check if an interrupt is enabled or disabled. 38.6.7 using the peripheral dma controller to relieve the cpu of data transfers the awire uart user interface support using the peripheral dma controller. to transmit using the peripheral dma controller do the following: 1. setup the awire uart user interface in transmit mode. 2. setup the peripheral dma controller with buffer address and length, use byte as trans- fer size. 3. enable the peripheral dma controller. 4. wait until the peripheral dma controller is done. to receive using the peripheral dma controller do the following: 1. setup the awire uart user interface in receive mode 2. setup the peripheral dma controller with buffer address and length, use byte as trans- fer size. 3. enable the peripheral dma controller. 4. wait until the peripheral dma controller is ready.
1181 32117b?avr-03/11 at32uc3c 38.7 user interface note: 1. the reset values are device specific. please refer to the module configuration section at the end of this chapter. table 38-2. awire uart user interface register memory map offset register register name access reset 0x00 control register ctrl read/write 0x00000000 0x04 status register sr read-only 0x00000000 0x08 status clear register scr write-only - 0x0c interrupt enable register ier write-only - 0x10 interrupt disable register idr write-only - 0x14 interrupt mask register imr read-only 0x00000000 0x18 receive holding register rhr read-only 0x00000000 0x1c transmit holding register thr read/write 0x00000000 0x20 baud rate register brr read/write 0x00000000 0x24 version register version read-only - (1) 0x28 clock request register clkr read/write 0x00000000
1182 32117b?avr-03/11 at32uc3c 38.7.1 control register name: ctrl access type: read/write offset: 0x00 reset value: 0x00000000 ? mode: awire uart user interface mode 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------ mode table 38-3. awire uart user interface modes mode mode description 0 disabled 1receive 2 transmit 3 receive with resync.
1183 32117b?avr-03/11 at32uc3c 38.7.2 status register name: sr access type: read-only offset: 0x04 reset value: 0x00000000 ? trmis: transmit mismatch 0: no transfers mismatches. 1: the transceiver was active when receiving. this bit is set when the transce iver is active when receiving. this bit is cleared when corresponding bit in scr is written to one. ? overrun: data overrun 0: no data overwritten in rhr. 1: data in rhr has been overwritten before it has been read. this bit is set when data in rhr is overwritten before it has been read. this bit is cleared when corresponding bit in scr is written to one. ? dreadyint: data ready interrupt 0: no new data in the rhr. 1: new data received and placed in the rhr. this bit is set when new data is received and placed in the rhr. this bit is cleared when corresponding bit in scr is written to one. ? readyint: ready interrupt 0: the interface has not generated an ready interrupt. 1: the interface has had a transition from busy to not busy. this bit is set when the interface has transition from busy to not busy. this bit is cleared when corresponding bit in scr is written to one. ? cenabled: clock enabled 0: the awire clock is not enabled. 1: the awire clock is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - trmis - - overrun dreadyint readyint 76543210 - - - - - cenabled - busy
1184 32117b?avr-03/11 at32uc3c this bit is set when the clock is disabled. this bit is cleared when the clock is enabled. ? busy: synchronizer busy 0: the asynchronous interface is ready to accept more data. 1: the asynchronous interface is busy and will block writes to ctrl, brr, and thr. this bit is set when the asynchronous interface becomes busy. this bit is cleared when the asynchronous interface becomes ready.
1185 32117b?avr-03/11 at32uc3c 38.7.3 status clear register name: scr access type: write-only offset: 0x08 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in sr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - trmis - - overrun dreadyint readyint 76543210 --------
1186 32117b?avr-03/11 at32uc3c 38.7.4 interrupt enable register name: ier access type: write-only offset: 0x0c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - trmis - - overrun dreadyint readyint 76543210 --------
1187 32117b?avr-03/11 at32uc3c 38.7.5 interrupt disable register name: idr access type: write-only offset: 0x10 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - trmis - - overrun dreadyint readyint 76543210 --------
1188 32117b?avr-03/11 at32uc3c 38.7.6 interrupt mask register name: imr access type: read-only offset: 0x14 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - trmis - - overrun dreadyint readyint 76543210 --------
1189 32117b?avr-03/11 at32uc3c 38.7.7 receive holding register name: rhr access type: read-only offset: 0x18 reset value: 0x00000000 ? rxdata: received data the last byte received. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 rxdata
1190 32117b?avr-03/11 at32uc3c 38.7.8 transmit holding register name: thr access type: read/write offset: 0x1c reset value: 0x00000000 ? txdata: transmit data the data to send. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 txdata
1191 32117b?avr-03/11 at32uc3c 38.7.9 baud rate register name: brr access type: read/write offset: 0x20 reset value: 0x00000000 ? br: baud rate the baud rate ( ) of the transmission, calculated us ing the following formula ( is the rc120m frequency): br should not be set to a value smaller than 32. writing a value to this field will update the baud rate of the transmission. reading this field will give the current baud rate of the transmission. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 br[15:8] 76543210 br[7:0] f br f aw f br 8 f aw br ----------- =
1192 32117b?avr-03/11 at32uc3c 38.7.10 version register name: version access type: read-only offset: 0x24 reset value: 0x00000200 ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
1193 32117b?avr-03/11 at32uc3c 38.7.11 clock request register name: clkr access type: read/write offset: 0x28 reset value: 0x00000000 ? clken: clock enable 0: the awire clock is disabled. 1: the awire clock is enabled. writing a zero to this bit will disable the awire clock. writing a one to this bit will enable the awire clock. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------clken
1194 32117b?avr-03/11 at32uc3c 38.8 module configuration the specific configuration for each awire instan ce is listed in the fo llowing tables. the module bus clocks listed here are connected to the syst em bus clocks. please refer to the power man- ager chapter for details. table 38-4. module clock name module name clock name description awire clk_aw peripheral bus clock from the pba clock domain table 38-5. register reset values register reset value version 0x00000230
1195 32117b?avr-03/11 at32uc3c 39. programming and debugging 39.1 overview the at32uc3c supports programming and debugging through two interfaces, jtag or awire ? . jtag is an industry standard interface and allows boundary scan for pcb testing, as well as daisy-chaining of multiple devices on the pcb. awire is an atmel proprietary protocol which offers higher throughput and robust communication, and does not require application pins to be reserved. either interface provides access to the internal service access bus (sab), which offers a bridge to the high speed bus, giving access to memories and peripherals in the device. by using this bridge to the bus system, the flas h and fuses can thus be programmed by access- ing the flash controller in the same manner as the cpu. the sab also provides access to the nexus-compliant on-chip debug (ocd) system in the device, which gives the user non-intrusive run-time control of the program execution. addition- ally, trace information can be output on the auxiliary (aux) deb ug port or buff ered in internal ram for later retrieval by jtag or awire. 39.2 service access bus the avr32 architecture offers a common interface for access to on-chip debug, programming, and test functions. these are mapped on a common bus called t he service acce ss bus (sab), which is linked to the jtag and awire port th rough a bus master module, which also handles synchronization between th e debugger and sab clocks. when accessing the sab through th e debugger ther e are no limitations on debugger frequency compared to chip frequency, although there must be an active system clock in order for the sab accesses to complete. if the system clock is swit ched off in sleep mode, activity on the debugger will restart the system clock automatically, without waking the device from sleep. debuggers may optimize the transfer rate by adjusting the frequency in relation to the system clock. this ratio can be measured with debug protocol specific instructions. the service access bus uses 36 address bits to address memory or registers in any of the slaves on the bus. the bus supports sized accesses of bytes (8 bits), halfwords (16 bits), or words (32 bits). all accesses must be aligned to the size of th e access, i.e. halfword accesses must have the lowest address bit cleared, and word accesses must have the two lowest address bits cleared. 39.2.1 sab address map the service access bus (sab) gives the user access to the internal address space and other features through a 36 bits address space. the 4 msbs identify the slave number, while the 32 lsbs are decoded within the slave?s address space. the sab slaves are shown in table 39-1 on page 1195 . table 39-1. sab slaves, addresses and descriptions. slave address [35:32] description unallocated 0x0 intentionally unallocated ocd 0x1 ocd registers hsb 0x4 hsb memory space, as seen by the cpu
1196 32117b?avr-03/11 at32uc3c 39.2.2 sab security restrictions the service access bus can be restricted by internal security measures. a short description of the security measures are found in the table below. 39.2.2.1 security measure and control location a security measure is a mechanism to either block or a llow sab access to a certain address or address range. a security measure is enabled or disabled by one or several control signals. this is called the control location for the security measure. these security measures can be used to prevent an end user from reading out the code pro- grammed in the flash, for instance. below follows a more in depth description of what locations are accessible when the security measures are active. hsb 0x5 alternative mapping for hsb space, for compatibility with other 32-bit avr devices. memory service unit 0x6 memory service unit registers reserved other unused table 39-1. sab slaves, addresses and descriptions. slave address [35:32] description table 39-2. sab security measures security measure control location description security bit flashc security bit set programming and debugging not possible, very restricted access. user code programming flashc uprot + security bit set restricts all access except parts of the flash and the flash controller for programming user code. debugging is not possible unless an os running from the secure part of the flash supports it. table 39-3. security bit sab restrictions name address start address end access ocd dccpu, ocd dcemu, ocd dcsr 0x100000110 0x100000118 read/write user page 0x580800000 0x581000000 read other accesses - - blocked
1197 32117b?avr-03/11 at32uc3c table 39-4. user code programming sab restrictions name address start address end access ocd dccpu, ocd dcemu, ocd dcsr 0x100000110 0x100000118 read/write user page 0x580800000 0x581000000 read flashcdw pb interface 0x5fffe0000 0x5fffe0400 read/write flash pages outside bootprot 0x580000000 + bootprot size 0x580000000 + flash size read/write other accesses - - blocked
1198 32117b?avr-03/11 at32uc3c 39.3 on-chip debug rev: 2.0.0.0 39.3.1 features ? debug interface in compli ance with ieee-isto 5001- 2003 (nexus 2.0) class 2+ ? jtag or awire access to all on-chip debug functions ? advanced program, data, ownership, and watchpoint trace supported ? nanotrace awire- or jtag-based trace access ? auxiliary port for high-speed trace information ? hardware support for 6 prog ram and 2 data breakpoints ? unlimited number of softw are breakpoints supported ? automatic crc check of memory regions 39.3.2 overview debugging on the at32uc3c is facilitated by a powerful on-chip debug (ocd) system. the user accesses this through an external debug tool which connects to the jtag or awire port and the auxiliary (aux) port if implemented. t he aux port is primarily used for trace functions, and an awire- or jtag-based debugger is sufficient for basic debugging. the debug system is based on the nexus 2.0 standard, class 2+, which includes: ? basic run-time control ? program breakpoints ? data breakpoints ?program trace ? ownership trace ? data trace in addition to the mandatory nexus debug features, the at32uc3c implements several useful ocd features, such as: ? debug communication channel between cpu and debugger ? run-time pc monitoring ? crc checking ? nanotrace ? software quality assurance (sqa) support the ocd features are controlled by ocd registers, which can be accessed by the debugger, for instance when the nexus_access jtag inst ruction is loaded. the cpu can also access ocd registers directly using mtdr/mfdr instructions in any privileged mode. the ocd registers are implemented based on the recommendations in the nexus 2.0 standard, and are detailed in the avr32uc technical reference manual. 39.3.3 i/o lines description the ocd aux trace port contains a number of pins, as shown in table 39-5 on page 1199 . these are multiplexed with i/o co ntroller lines, and must explicit ly be enabled by writing ocd registers before the debug session starts. the aux port is mapped to two different locations,
1199 32117b?avr-03/11 at32uc3c selectable by ocd registers, minimizing the chance that the aux port will need to be shared with an application. 39.3.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 39.3.4.1 power management the ocd clock operates independently of the cpu clock. if enabled in the power manager, the ocd clock (clk_ocd) will continue running even if the cpu enters a sleep mode that disables the cpu clock. 39.3.4.2 clocks the ocd has a clock (clk_ocd) running synchronou sly with the cpu clock. this clock is gen- erated by the power manager. the clock is enabled at reset, and can be disabled by writing to the power manager. 39.3.4.3 interrupt the ocd system interrupt request lines are connected to the interrupt controller. using the ocd interrupts requires the interrupt controller to be programmed first. table 39-5. auxiliary port signals pin name pin description direction active level type mcko trace data output clock output digital mdo[5:0] trace data output output digital mseo[1:0] trace frame control output digital evti_n event in input low digital evto_n event out output low digital
1200 32117b?avr-03/11 at32uc3c 39.3.5 block diagram figure 39-1. on-chip debug block diagram 39.3.6 sab-based debug features a debugger can control all ocd fe atures by writing ocd register s over the sab interface. many of these do not depend on output on the aux port, allowing an awire- or jtag-based debugger to be used. a jtag-based debugger should connect to the device through a standard 10-pin idc connector as described in the avr32uc technical reference manual. an awire-based deb ugger should connect to the device through the reset_n pin. on-chip debug jtag debug pc debug instruction cpu breakpoints program trace data trace ownership trace watchpoints transmit queue aux jtag internal sram s e r v i c e a c c e s s b u s memory service unit hsb bus matrix memories and peripherals awire awire
1201 32117b?avr-03/11 at32uc3c figure 39-2. jtag-based debugger figure 39-3. awire-based debugger 39.3.6.1 debug communication channel the debug communication channel (d cc) consists of a pair ocd registers with associated handshake logic, accessible to both cpu and debugger. the registers can be used to exchange data between the cpu and the debugmaster, both runtime as well as in debug mode. 32-bit avr jtag-based debug tool pc jtag 10-pin idc 32-bit avr awire-based debug tool pc awire
1202 32117b?avr-03/11 at32uc3c the ocd system can generate an interrupt to the cpu when dccpu is read and when dcemu is written. this enables the user to build a cust um debug protocol using only these registers. the dccpu and dcemu registers are available even when the security bit in the flash is active. for more information refer to the avr32uc technical reference manual. 39.3.6.2 breakpoints one of the most fundamental debug features is the abilit y to halt the cpu, to examine registers and the state of the system. this is accomplish ed by breakpoints, of which many types are available: ? unconditional breakpoints are set by writing ocd registers by the debugger, halting the cpu immediately. ? program breakpoints halt the cpu when a specific address in the program is executed. ? data breakpoints halt the cpu when a specific memory address is read or written, allowing variables to be watched. ? software breakpoints halt the cpu when the breakpoint instruction is executed. when a breakpoint triggers, the cpu enters debug mode, and the d bit in the status register is set. this is a privileged mode with dedicated return address and return status registers. all privi- leged instructions are permitted. debug mode can be entered as either ocd mode, running instructions from the debugger, or monitor mode, running instructions from program memory. 39.3.6.3 ocd mode when a breakpoint triggers, the cpu enters ocd mode, and instructions are fetched from the debug instruction ocd register. each time this register is written by the debugger, the instruc- tion is executed, allowing the debugger to execut e cpu instructions directly. the debug master can e.g. read out the register file by issuing mtdr instructions to the cpu, writing each register to the debug communication channel ocd registers. 39.3.6.4 monitor mode since the ocd registers are directly accessible by the cpu, it is possible to build a software- based debugger that runs on the cpu itself. setting the monitor mode bit in the development control register causes the cpu to enter monitor mode instead of ocd mode when a breakpoint triggers. monitor mode is similar to ocd mode, except that instructions are fetched from the debug exception vector in regular program memory, instead of issued by the debug master. 39.3.6.5 program counter monitoring normally, the cpu would need to be halted for a debugger to examine the current pc value. however, the at32uc3c also proves a debug program counter ocd register, where the debugger can continuously read the current pc without affecting the cpu. this allows the debugger to generate a simple statistic of the time spent in various areas of the code, easing code optimization. 39.3.7 memory service unit the memory service unit (msu) is a block dedicated to test and debug functionality. it is con- trolled through a dedicated set of registers addressed through the service access bus.
1203 32117b?avr-03/11 at32uc3c 39.3.7.1 cyclic redundancy check (crc) the msu can be used to automatically calculate the crc of a block of data in memory. the msu will then read out each word in the specif ied memory block and re port the crc32-value in an msu register. 39.3.7.2 nanotrace the msu additionally supports nanotrace. this is a 32-bit avr-specific feature, in which trace data is output to memory instead of the aux port . this allows the trace data to be extracted by the debugger through the sab, enabling trace features for awire- or jtag-based debuggers. the user must write msu registers to configure the address and size of the memory block to be used for nanotrace. the nanotrace buffer can be anywhere in the physical address range, including internal and external ram, through an ebi, if present. this area may not be used by the application running on the cpu. 39.3.8 aux-based debug features utilizing the auxiliary (aux) port gives a ccess to a wide range of advanced debug features. of prime importance are the trace features, which allow an external debugger to receive continuous information on the program execution in the cpu. additionally, event in and event out pins allow external events to be correlated with the program flow. debug tools utilizing the aux port should connec t to the device throug h a nexus-compliant mic- tor-38 connector, as described in the avr32uc technical reference manual. this connector includes the jtag signals and the reset_n pin, giving full access to the programming and debug features in the device.
1204 32117b?avr-03/11 at32uc3c figure 39-4. aux+jtag based debugger 39.3.8.1 trace operation trace features are enabled by writing ocd re gisters by the debugger. the ocd extracts the trace information from the cpu, compresses this information and formats it into variable-length messages according to the nexus standard. the messages are buffered in a 16-frame transmit queue, and are output on the aux port one frame at a time. the trace features can be configured to be very selective, to reduce the bandwidth on the aux port. in case the transmit queue overflows, er ror messages are produced to indicate loss of data. the transmit queue module can optionally be configured to halt the cpu when an overflow occurs, to prevent the loss of messages, at the expense of longer run-time for the program. 39.3.8.2 program trace program trace allows the debugger to continuously monitor the program execution in the cpu. program trace messages are generated for every branch in the program, and contains com- pressed information, which allows the debugger to correlate the message with the source code to identify the branch instruction and target address. 39.3.8.3 data trace data trace outputs a message every time a specific location is read or written. the message contains information about the type (read/write) and size of the access, as well as the address and data of the accessed location. the at32uc3 c contains two data trace channels, each of avr32 aux+jtag debug tool jtag aux high speed mictor38 trace buffer pc
1205 32117b?avr-03/11 at32uc3c which are controlled by a pair of ocd registers which determine the range of addresses (or sin- gle address) which should produce data trace messages. 39.3.8.4 ownership trace program and data trace operate on virtual addresses. in cases where an operating system runs several processes in overlapping virtual memory segments, the ownership trace feature can be used to identify th e process switch. when the o/s activates a process, it will write the process id number to an ocd register, which produces an ownership trace message, allowing the debug- ger to switch context for the subsequent progra m and data trace messages. as the use of this feature depends on the software running on the cpu, it can also be used to extract other types of information from the system. 39.3.8.5 watchpoint messages the breakpoint modules normally used to generate program and data breakpoints can also be used to generate watchpoint messages, allowing a debugger to monitor program and data events without halting the cpu. watchpoints can be enabled independently of breakpoints, so a breakpoint module can optionally halt the cpu w hen the trigger condition occurs. data trace modules can also be configured to produce watc hpoint messages instead of regular data trace messages. 39.3.8.6 event in and event out pins the aux port also contains an event in pin (evti_n) and an event out pin (evto_n). evti_n can be used to trigger a breakpoint when an external event occurs. it can also be used to trigger specific program and data trace synchronization messages, allowing an external event to be correlated to the program flow. when the cpu enters debug mode, a debug status message is transmitted on the trace port. all trace messages can be timestamped when they are received by the debug tool. however, due to the latency of the trans mit queue buffering, the timest amp will not be 100% accurate. to improve this, evto_n can toggle every time a message is inserted into the transmit queue, allowing trace messages to be timestamped prec isely. evto_n can also toggle when a break- point module triggers, or when the cpu enters debug mode, for any reason. this can be used to measure precisely when the respective internal event occurs. 39.3.8.7 software quality analysis (sqa) software quality analysis (sqa) deals with two important issues regarding embedded software development. code coverage involves identifying untested parts of the embedded code, to improve test procedures and thus the quality of the released software. performance analysis allows the developer to precisely quantify the time spent in various parts of the code, allowing bottlenecks to be identified and optimized. program trace must be used to accomplish these tasks without instrumenting (altering) the code to be examined. however, traditional program trace cannot reconstruct the current pc value without correlating the trace information with the source code, which cannot be done on-the-fly. this limits program trace to a relatively short time segment, determined by the size of the trace buffer in the debug tool. the ocd system in at32uc3c extends program trace with sqa capabilities, allowing the debug tool to reconstruct the pc value on-the-f ly. code coverage and performance analysis can thus be reported for an unlimited execution sequence.
1206 32117b?avr-03/11 at32uc3c 39.4 jtag and boundary-scan (jtag) rev: 2.3.0.4 39.4.1 features ? ieee1149.1 compli ant jtag interface ? boundary-scan chain fo r board-level testing ? direct memory access and programming capabilities through jtag interface 39.4.2 overview the jtag interface offers a four pin programming and debug solution, including boundary-scan support for board-level testing. figure 39-5 on page 1207 shows how the jtag is connected in an 32-bit avr device. the tap controller is a state machine controlled by the tck and tms signals. the tap controller selects either the jtag instruction register or one of several data registers as the scan chain (shift register) between the tdi-input and tdo-output. the instruction register holds jt ag instructions controlling the be havior of a data register. the device identification register, bypass register , and the boundary-scan chain are the data reg- isters used for board-level testing. the reset register can be used to keep the device reset during test or programming. the service access bus (sab) interface cont ains address and data registers for the service access bus, which gives access to on-chip debug, programming, and other functions in the device. the sab offers se veral modes of access to the addr ess and data regist ers, as described in section 39.4.11 . section 39.5 lists the supported jtag instructions, wit h references to the description in this document.
1207 32117b?avr-03/11 at32uc3c 39.4.3 block diagram figure 39-5. jtag and boundary-scan access 39.4.4 i/o lines description 39.4.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. table 39-6. i/o line description pin name pin description type active level reset_n external reset pin. used when enabling and disabling the jtag. input low tck test clock input. fully asynchronous to system clock frequency. input tms test mode select, sampled on rising tck. input tdi test data in, sampled on rising tck. input tdo test data out, driven on falling tck. output 32-bit avr device jtag data registers tap controller instruction register device identification register by-pass register reset register service access bus interface boundary scan chain pins and analog blocks data register scan enable jtag pins boundary scan enable 2nd jtag device jtag master tdi tdo part specific registers ... tdo tdi tms tms tck tck instruction register scan enable sab internal i/o lines jtag tms tdi tdo tck
1208 32117b?avr-03/11 at32uc3c 39.4.5.1 i/o lines the tms, tdi, tdo, and tck pins are multiplexed with i/o lines. when the jtag is used the associated pins must be enabled. to enable the jtag pins, refer to section 39.4.7 . while using the multiplexed jtag lines all norma l peripheral activity on these lines is disabled. the user must make sure that no external peripheral is blocking the jtag lines while debugging. 39.4.5.2 power management when an instruction that accesses the sab is loaded in the instruction register, before entering a sleep mode, the system clocks are not switched off to a llow debugging in sleep modes. this can lead to a program behaving differently when debugging. 39.4.5.3 clocks the jtag interface uses the external tck pin as clock source. this clock must be provided by the jtag master. instructions that use the sab bus requires the internal main clock to be running. 39.4.6 jtag interface the jtag interface is accessed through the dedicated jtag pins shown in table 39-6 on page 1207 . the tms control line navigates the tap controller, as shown in figure 39-6 on page 1209 . the tap controller manages the serial access to the jtag instruction and data registers. data is scanned into the selected instruction or data register on tdi, and out of the register on tdo, in the shift-ir and shift-dr states, respectively. th e lsb is shifted in and out first. tdo is high- z in other states than shift-ir and shift-dr. the device implements a 5-bit instruction regist er (ir). a number of public jtag instructions defined by the jtag standard are supported, as described in section 39.5.2 , as well as a num- ber of 32-bit avr-specific private jtag instructions described in section 39.5.3 . each instruction selects a specific data register for the shift-dr path, as described for each instruction.
1209 32117b?avr-03/11 at32uc3c figure 39-6. tap controller state diagram test-logic- reset run-test/ idle select-dr scan select-ir scan capture-dr capture-ir shift-dr shift-ir exit1-dr exit1-ir pause-dr pause-ir exit2-dr exit2-ir update-dr update-ir 0 1 1 1 0 0 1 0 1 1 0 0 1 0 1 1 1 0 1 1 0 0 1 1 0 1 0 0 0 0 0 1
1210 32117b?avr-03/11 at32uc3c 39.4.7 how to initialize the module to enable the jtag pins the tck pin must be held low while the reset_n pin is released. after enabling the jtag interface the halt bit is set automatically to prevent the system from run- ning code after the interface is enabled. to make the cpu run again set halt to zero using the halt command.. jtag operation when reset_n is pulled low is not possible. independent of the initial state of the tap controller, the test-logic-reset state can always be entered by holding tms high for 5 tck clock periods. this sequence should always be applied at the start of a jtag session and after enabling the jtag pins to bring the tap controller into a defined state before applying jtag commands. applying a 0 on tms for 1 tck period brings the tap controller to the run-test/idle state, which is the starting point for jtag operations. 39.4.8 how to disable the module to disable the jtag pins the tck pin must be held high while reset _n pin is released. 39.4.9 typical sequence assuming run-test/idle is the present state, a typical scenario for using the jtag interface follows. 39.4.9.1 scanning in jtag instruction at the tms input, apply the sequence 1, 1, 0, 0 at the rising edges of tck to enter the shift instruction register (shift-ir) state. while in this state, shift the 5 bits of the jtag instructions into the jtag instruction register from the tdi input at the rising edge of tck. during shifting, the jtag outputs status bits on tdo, refer to section 39.5 for a description of these. the tms input must be held low during input of the 4 lsbs in order to remain in the shift-ir state. the jtag instruction selects a particular data register as path between tdi and tdo and controls the circuitry surrounding th e selected data register. apply the tms sequence 1, 1, 0 to re-enter the run-test/idle state. the instruction is latched onto the parallel output from the shift register path in the update-ir state. the exit-ir, pause-ir, and exit2-ir states are only used for navigating the state machine. figure 39-7. scanning in jtag instruction 39.4.9.2 scanning in/out data at the tms input, apply the sequence 1, 0, 0 at the rising edges of tck to enter the shift data register (shift-dr) state. while in this state, upload the selected data register (selected by the present jtag instruction in the jtag instruction register) from the tdi input at the rising edge tck tap state tlr rti seldr selir capir shir ex1ir updir rti tms tdi instruction tdo impldefined
1211 32117b?avr-03/11 at32uc3c of tck. in order to remain in the shift-dr state, the tms input must be held low. while the data register is shifted in from the tdi pin, the parallel inputs to the data register captured in the capture-dr state is shifted out on the tdo pin. apply the tms sequence 1, 1, 0 to re-enter the run-test/idle state. if the selected data register has a latched parallel-output, the latching takes place in the update-dr state. the exit-dr, pause-dr, and exit2-dr states are only used for navigating the state machine. as shown in the state diagram, the run-test/idle state need not be entered between selecting jtag instruction and using data registers. 39.4.10 boundary-scan the boundary-scan chain has the c apability of driving an d observing the logic levels on the digi- tal i/o pins, as well as the boundary between digi tal and analog logic for analog circuitry having off-chip connections. at system level, all ics having jtag capabilities ar e connected serially by the tdi/tdo signals to form a long shift register. an external controller sets up the devices to drive values at their output pins, and observe the input values received from other devices. the controller compares the received data with the expected result. in this way, boundary-scan pro- vides a mechanism for testing interconnections and integrity of components on printed circuits boards by using the 4 tap signals only. the four ieee 1149.1 defined mandatory jtag in structions idcode, bypass, sample/pre- load, and extest can be used for testing the printed circuit board. initial scanning of the data register path will show th e id-code of the device, sinc e idcode is the default jtag instruction. it may be desirable to have the 32-bit avr device in reset during test mode. if not reset, inputs to the device may be determined by the scan operations, and the internal software may be in an undetermi ned state when exiting the test mode. if nee ded, the bypass instruction can be issued to make the shortest possible scan chain through the device. the device can be set in the reset state either by pulling the external resetn pi n low, or issuing the avr_reset instruction with appropriate setting of the reset data register. the extest instruction is used for sampling external pins and loading output pins with data. the data from the output latch will be driven out on the pins as soon as the extest instruction is loaded into the jtag ir-register. therefore, the sample/preload should also be used for setting initial values to the scan ring, to avoid damaging the board when issuing the extest instruction for the first time. sample/preload c an also be used for taking a snapshot of the external pins during normal operation of the part. when using the jtag interface for boundary-scan, the jtag tck clock is independent of the internal chip clock. the internal chip clock is not required to run during boundary-scan operations. note: for pins connected to 5v lines care should be taken to not drive the pins to a logic one using boundary-scan, as this will create a current fl owing from the 3,3v driver to the 5v pull-up on the line. optionally a series resistor can be added between the line and the pin to reduce the current. details about the boundary-scan chain can be found in the bsdl file for the device. this can be found on the atmel website. 39.4.11 service access bus the avr32 architecture offers a common interface for access to on-chip debug, programming, and test functions. these are mapped on a common bus called t he service acce ss bus (sab),
1212 32117b?avr-03/11 at32uc3c which is linked to the jtag through a bus master module, which also handles synchronization between the tck and sab clocks. for more information about the sab and a list of sab slaves see the service access bus chapter. 39.4.11.1 sab address mode the memory_sized_access instruction allows a sized read or write to any 36-bit address on the bus. memory_word_access is a shorthand instruction for 32-bit accesses to any 36-bit address, while the nexus_access instruct ion is a nexus-compliant shorthand instruc- tion for accessing the 32-bit ocd registers in the 7-bit address space reserved for these. these instructions require two passes through the shift-dr tap state: one for the address and control information, and one for data. 39.4.11.2 block transfer to increase the transfer rate, consecutive me mory accesses can be accomplished by the memory_block_access instruction, which only r equires a single pass through shift-dr for data transfer only. the address is automatically incremented according to the size of the last sab transfer. 39.4.11.3 canceling a sab access it is possible to abort an ongoing sab access by the cancel_access instruction, to avoid hanging the bus due to an extremely slow slave. 39.4.11.4 busy reporting as the time taken to perform an access may vary depending on system activity and current chip frequency, all the sab access jtag instructions can return a busy indicator. this indicates whether a delay needs to be inserted, or an operation needs to be repeated in order to be suc- cessful. if a new acce ss is requested while the sab is busy, the request is ignored. the sab becomes busy when: ? entering update-dr in the address phase of any read operation, e.g., after scanning in a nexus_access address wit h the read bit set. ? entering update-dr in the data phase of any write operation, e.g., after scanning in data for a nexus_access write. ? entering update-dr during a memory_block_access. ? entering update-dr after scanning in a counter value for sync. ? entering update-ir af ter scanning in a memory_block _access if the previous access was a read and data was scanned after scanning the address. the sab becomes ready again when: ? a read or write operation completes. ? a sync countdown completed. ? a operation is cancelled by the cancel_access instruction. what to do if the busy bit is set: ? during shift-ir: the new instruction is selected, but the previous operation has not yet completed and will continue (u nless the new instruction is cancel_access). you may
1213 32117b?avr-03/11 at32uc3c continue shifting the same instruction until the busy bit clears, or start shifting data. if shifting data, you must be prepared that the data shift may also report busy. ? during shift-dr of an address: the new address is ignored. the sab stays in address mode, so no data must be shifted. repeat the address until the busy bit clears. ? during shift-dr of read data: the read data is invalid. the sab stays in data mode. repeat scanning until the busy bit clears. ? during shift-dr of write data: the write data is ignored. the sab stays in data mode. repeat scanning until the busy bit clears. 39.4.11.5 error reporting the service access bus may not be able to comp lete all accesses as requested. this may be because the address is invalid, the addressed area is read-only or cannot handle byte/halfword accesses, or because the chip is set in a protected mode where only limited accesses are allowed. the error bit is updated when an access complete s, and is cleared when a new access starts. what to do if the error bit is set: ? during shift-ir: the new instruction is selected. the last operation performed using the old instruction did not complete successfully. ? during shift-dr of an address: the previous operation failed. the new address is accepted. if the read bit is set, a read operation is started. ? during shift-dr of read data: the read operation failed, and the read data is invalid. ? during shift-dr of write data: the previous write operation failed. the new data is accepted and a write operation started. this should only occur during block writes or stream writes. no error can occur between scanning a write address and the following write data. ? while polling with cancel_access: the previous access was cancelled. it may or may not have actually completed. ? after power-up: the error bit is set after power up, but there has been no previous sab instruction so this error can be discarded. 39.4.11.6 protected reporting a protected status may be reported during shift-ir or shift-dr. this indicates that the security bit in the flash controller is set and that the chip is locked for access, according to section 39.5.1 . the protected state is reported when: ? the flash controller is under reset. this can be due to the avr_reset command or the reset_n line. ? the flash controller has not read the security bit from the flash yet (this will take a a few ms). happens after the flash controller reset has been released. ? the security bit in the flash controller is set. what to do if the protected bit is set: ? release all active avr_ reset domains, if any. ? release the reset_n line. ? wait a few ms for the security bit to clear. it can be set temporarily due to a reset.
1214 32117b?avr-03/11 at32uc3c ? perform a chip_erase to clear the security bit. note : this will erase all the contents of the non-volatile memory. 39.5 jtag instruction summary the implemented jtag instructions in the 32-bit avr are shown in the table below. 39.5.1 security restrictions when the security fuse in the flash is programmed, the following jtag instructions are restricted: ? nexus_access ? memory_word_access ? memory_block_access ? memory_sized_access for description of what memory locations remain accessible, please refer to the sab address map. full access to these instructions is re-enabled when the security fuse is erased by the chip_erase jtag instruction. table 39-7. jtag instruction summary instruction opcode instruction description 0x01 idcode select the 32-bit device ident ification register as data register. 0x02 sample_preload take a snapshot of external pin values without affe cting system operation. 0x03 extest select boundary-scan chain as data register for testing circuitry external to the device. 0x04 intest select boundary-scan chain for internal testing of the device. 0x06 clamp bypass device through bypass register, while driving outputs from boundary- scan register. 0x0c avr_reset apply or remove a static reset to the device 0x0f chip_erase erase the device 0x10 nexus_access select the sab address and data regist ers as data register for the tap. the registers are accessed in nexus mode. 0x11 memory_word_access select the sab address an d data registers as data register for the tap. 0x12 memory_block_access select the sab data register as data register for the tap. the address is auto-incremented. 0x13 cancel_access cancel an ongoing nexus or memory access. 0x14 memory_service select the sab address and data regist ers as data register for the tap. the registers are accessed in memory service mode. 0x15 memory_sized_access select the sab address an d data registers as data register for the tap. 0x17 sync synchronization counter 0x1c halt halt the cpu for safe programming. 0x1f bypass bypass this device through the bypass register. others n/a acts as bypass
1215 32117b?avr-03/11 at32uc3c note that the security bit will read as programmed and block these instructions also if the flash controller is statically reset. other security mechanisms can also restrict these functions. if such mechanisms are present they are listed in the sab address map section. 39.5.1.1 notation table 39-9 on page 1215 shows bit patterns to be shifted in a format like " peb01 ". each charac- ter corresponds to one bit, and eight bits are grouped together for readability. the least significantbit is always shifted first, and the mo st significant bit shifted last. the symbols used are shown in table 39-8 . in many cases, it is not required to shift all bits through the data register. bit patterns are shown using the full width of the shift register, but the suggested or required bits are emphasized using bold text. i.e. given the pattern " aaaaaaar xxxxxxxx xxxxxxxx xxxxxxxx xx", the shift register is 34 bits, but the test or debug unit may choose to shift only 8 bits " aaaaaaar ". the following describes how to interpret the fields in the instruction description tables: table 39-8. symbol description symbol description 0 constant low value - always reads as zero. 1 constant high value - always reads as one. a an address bit - always scanned with the least significant bit first b a busy bit. reads as one if the sab was busy, or zero if it was not. see section 39.4.11.4 for details on how the busy reporting works. d a data bit - always scanned with the least significant bit first. e an error bit. reads as one if an error occurred, or zero if not. see section 39.4.11.5 for details on how the error reporting works. p the chip protected bit. some devices may be se t in a protected state where access to chip internals are severely restricted. see the docum entation for the specific device for details. on devices without this possibility, this bit always reads as zero. r a direction bit. set to one to request a read, set to zero to request a write. s a size bit. the size encoding is described where used. x a don?t care bit. any value can be shifted in, and output data should be ignored. table 39-9. instruction description instruction description ir input value shows the bit pattern to shift into ir in t he shift-ir state in order to select this instruction. the pattern is show both in binary and in hexadecimal form for convenience. example: 10000 (0x10) ir output value shows the bit pattern shifted out of ir in t he shift-ir state when this instruction is active. example: peb01
1216 32117b?avr-03/11 at32uc3c 39.5.2 public jtag instructions the jtag standard defines a number of public jtag instructions. these instructions are described in the sections below. 39.5.2.1 idcode this instruction selects the 32 bit device identification register (did) as data register. the did register consists of a version number, a device number, and the manufacturer code chosen by jedec. this is the default instruction after a jtag reset. details about the did register can be found in the module configuration section at the end of this chapter. starting in run-test/idle, the device identification register is accessed in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in capture-dr: the idcode value is latched into the shift register. 7. in shift-dr: the idcode scan ch ain is shifted by the tck input. 8. return to run-test/idle. 39.5.2.2 sample_preload this instruction takes a snap-shot of the input/ output pins without affect ing the system operation, and pre-loading the scan chain without updating the dr-latch. the boundary-scan chain is selected as data register. starting in run-test/idle, the device identification register is accessed in the following way: dr size shows the number of bits in the data register chain when this instruction is active. example: 34 bits dr input value shows which bit pattern to shift into the data register in the shift-dr state when this instruction is active. multiple such line s may exist, e.g., to distinguish between reads and writes. example: aaaaaaar xxxxxxxx xxxxxxxx xxxxxxxx xx dr output value shows the bit pattern shifted out of the dat a register in the sh ift-dr state when this instruction is active. multiple such line s may exist, e.g., to distinguish between reads and writes. example: xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb table 39-9. instruction description (continued) instruction description table 39-10. idcode details instructions details ir input value 00001 (0x01) ir output value p0001 dr size 32 dr input value xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx dr output value device identification register
1217 32117b?avr-03/11 at32uc3c 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in capture-dr: the data on the external pins are sampled into the boundary-scan chain. 7. in shift-dr: the boundary-scan chain is shifted by the tck input. 8. return to run-test/idle. 39.5.2.3 extest this instruction selects the boundary-scan chain as data register for testing circuitry external to the 32-bit avr package. the contents of the latched outputs of the boundary-scan chain is driven out as soon as the jtag ir-register is loaded with the extest instruction. starting in run-test/idle, the extest instruction is accessed the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. in update-ir: the data from the boundary-scan chain is applied to the output pins. 5. return to run-test/idle. 6. select the dr scan path. 7. in capture-dr: the data on the external pins is sampled into the boundary-scan chain. 8. in shift-dr: the boundary-scan chain is shifted by the tck input. 9. in update-dr: the data from the scan chain is applied to the output pins. 10. return to run-test/idle. table 39-11. sample_preload details instructions details ir input value 00010 (0x02) ir output value p0001 dr size depending on boundary-scan chain, see bsdl-file. dr input value depending on boundary-scan chain, see bsdl-file. dr output value depending on boundary-scan chain, see bsdl-file. table 39-12. extest details instructions details ir input value 00011 (0x03) ir output value p0001 dr size depending on boundary-scan chain, see bsdl-file. dr input value depending on boundary-scan chain, see bsdl-file. dr output value depending on boundary-scan chain, see bsdl-file.
1218 32117b?avr-03/11 at32uc3c 39.5.2.4 intest this instruction selects the boundary-scan chain as data register for testing internal logic in the device. the logic inputs are determined by the boundary-scan chain, and the logic outputs are captured by the boundary-scan chain. the device output pins are driven from the boundary-scan chain. starting in run-test/idle, the intest instruction is access ed the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. in update-ir: the data from the boundary-scan chain is applied to the internal logic inputs. 5. return to run-test/idle. 6. select the dr scan path. 7. in capture-dr: the data on the internal logic is sampled into the boundary-scan chain. 8. in shift-dr: the boundary-scan chain is shifted by the tck input. 9. in update-dr: the data from the boundary-scan chain is applied to internal logic inputs. 10. return to run-test/idle. 39.5.2.5 clamp this instruction selects the bypass register as data register. the device output pins are driven from the boundary-scan chain. starting in run-test/idle, the clamp instruction is acce ssed the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. in update-ir: the data from the boundary-scan chain is applied to the output pins. 5. return to run-test/idle. 6. select the dr scan path. 7. in capture-dr: a logic ?0? is loaded into the bypass register. 8. in shift-dr: data is scanned from tdi to tdo through the bypass register. table 39-13. intest details instructions details ir input value 00100 (0x04) ir output value p0001 dr size depending on boundary-scan chain, see bsdl-file. dr input value depending on boundary-scan chain, see bsdl-file. dr output value depending on boundary-scan chain, see bsdl-file.
1219 32117b?avr-03/11 at32uc3c 9. return to run-test/idle. 39.5.2.6 bypass this instruction selects the 1-bit bypass register as data register. starting in run-test/idle, the clamp instruction is acce ssed the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in capture-dr: a logic ?0? is loaded into the bypass register. 7. in shift-dr: data is scanned from tdi to tdo through the bypass register. 8. return to run-test/idle. 39.5.3 private jtag instructions the 32-bit avr defines a number of private jt ag instructions, not defined by the jtag stan- dard. each instruction is br iefly described in text, with det ails following in table form. 39.5.3.1 nexus_access this instruction allows nexus-compliant access to the on-chip debug registers through the sab. the 7-bit register index, a read/write co ntrol bit, and the 32-bit data is accessed through the jtag port. the data register is alternately interpreted by the sab as an address register and a data regis- ter. the sab starts in addre ss mode after the nexus_access instruction is selected, and toggles between address and data mode each time a data scan completes with the busy bit cleared. note : the polarity of the direction bit is inverse of the nexus standard. table 39-14. clamp details instructions details ir input value 00110 (0x06) ir output value p0001 dr size 1 dr input value x dr output value x table 39-15. bypass details instructions details ir input value 11111 (0x1f) ir output value p0001 dr size 1 dr input value x dr output value x
1220 32117b?avr-03/11 at32uc3c starting in run-test/idle, ocd registers are accessed in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in shift-dr: scan in the direction bit (1=read, 0=write) and the 7-bit address for the ocd register. 7. go to update-dr and re-enter select-dr scan. 8. in shift-dr: for a read operation, scan out the contents of the addressed register. for a write operation, scan in the new contents of the register. 9. return to run-test/idle. for any operation, the full 7 bits of the address must be provided. for write operations, 32 data bits must be provided, or the result will be undefined. for read ope rations, shifting may be termi- nated once the required number of bits have been acquired. 39.5.3.2 memory_service this instruction allows access to registers in an optional memory service unit. the 7-bit register index, a read/write control bit, and the 32-bit data is accessed through the jtag port. the data register is alternately interpreted by the sab as an address register and a data regis- ter. the sab starts in addres s mode after the memory_service instruction is selected, and toggles between address and data mode each time a data scan completes with the busy bit cleared. starting in run-test/idle, memory service registers are accessed in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in shift-dr: scan in the direction bit (1=read, 0=write) and the 7-bit address for the memory service register. table 39-16. nexus_access details instructions details ir input value 10000 (0x10) ir output value peb01 dr size 34 bits dr input value (address phase) aaaaaaar xxxxxxxx xxxxxxxx xxxxxxxx xx dr input value (data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xx dr input value (data write phase) dddddddd dddddddd dddddddd dddddddd xx dr output value (address phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb dr output value (data read phase) eb dddddddd dddddddd dddddddd dddddddd dr output value (data write phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb
1221 32117b?avr-03/11 at32uc3c 7. go to update-dr and re-enter select-dr scan. 8. in shift-dr: for a read operation, scan out the contents of the addressed register. for a write operation, scan in the new contents of the register. 9. return to run-test/idle. for any operation, the full 7 bits of the address must be provided. for write operations, 32 data bits must be provided, or the result will be undefined. for read ope rations, shifting may be termi- nated once the required number of bits have been acquired. 39.5.3.3 memory_sized_access this instruction allows access to the entire service access bus data area. data is accessed through a 36-bit byte index, a 2-bit size, a direction bit, and 8, 16, or 32 bits of data. not all units mapped on the sab bus may support all sizes of accesses, e.g., some may only support word accesses. the data register is alternately interpreted by the sab as an address register and a data regis- ter. the sab starts in address mode after the memory_sized_access instruction is selected, and toggles between address and data mode each time a data scan completes with the busy bit cleared. table 39-17. memory_service details instructions details ir input value 10100 (0x14) ir output value peb01 dr size 34 bits dr input value (address phase) aaaaaaar xxxxxxxx xxxxxxxx xxxxxxxx xx dr input value (data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xx dr input value (data write phase) dddddddd dddddddd dddddddd dddddddd xx dr output value (address phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb dr output value (data read phase) eb dddddddd dddddddd dddddddd dddddddd dr output value (data write phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb
1222 32117b?avr-03/11 at32uc3c the size field is encoded as i table 39-18 . starting in run-test/idle, sab data is accessed in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in shift-dr: scan in the direction bit (1=read, 0=write), 2-bit access size, and the 36-bit address of the data to access. 7. go to update-dr and re-enter select-dr scan. 8. in shift-dr: for a read operation, scan out the contents of the addressed area. for a write operation, scan in the new contents of the area. 9. return to run-test/idle. for any operation, the full 36 bits of the address must be provided. for write operations, 32 data bits must be provided, or the result will be undefined. for read ope rations, shifting may be termi- nated once the required number of bits have been acquired. table 39-18. size field semantics size field value access size data alignment 00 byte (8 bits) address modulo 4 : data alignment 0: dddddddd xxxxxxxx xxxxxxxx xxxxxxxx 1: xxxxxxxx dddddddd xxxxxxxx xxxxxxxx 2: xxxxxxxx xxxxxxxx dddddddd xxxxxxxx 3: xxxxxxxx xxxxxxxx xxxxxxxx dddddddd 01 halfword (16 bits) address modulo 4 : data alignment 0: dddddddd dddddddd xxxxxxxx xxxxxxxx 1: not allowed 2: xxxxxxxx xxxxxxxx dddddddd dddddddd 3: not allowed 10 word (32 bits) address modulo 4 : data alignment 0: dddddddd dddddddd dddddddd dddddddd 1: not allowed 2: not allowed 3: not allowed 11 reserved n/a table 39-19. memory_sized_access details instructions details ir input value 10101 (0x15) ir output value peb01 dr size 39 bits dr input value (address phase) aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aaaassr dr input value (data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxx dr input value (data write phase) dddddddd dddddddd dddddddd dddddddd xxxxxxx
1223 32117b?avr-03/11 at32uc3c 39.5.3.4 memory_word_access this instruction allows access to the entire service access bus data area. data is accessed through the 34 msb of the sab addr ess, a direction bit, and 32 bits of data. this instruction is identical to memory_sized_access except that it always does word sized accesses. the size field is implied, and the two lowest address bits are removed and not scanned in . note: this instruction was previously known as memory_access, and is provided for back- wards compatibility. the data register is alternately interpreted by the sab as an address register and a data regis- ter. the sab starts in address mode after the memory_word_access instruction is selected, and toggles between address and data mode each time a data scan completes with the busy bit cleared. starting in run-test/idle, sab data is accessed in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in shift-dr: scan in the direction bit (1=read, 0=write) and the 34-bit address of the data to access. 7. go to update-dr and re-enter select-dr scan. 8. in shift-dr: for a read operation, scan out the contents of the addressed area. for a write operation, scan in the new contents of the area. 9. return to run-test/idle. for any operation, the full 34 bits of the address must be provided. for write operations, 32 data bits must be provided, or the result will be undefined. for read ope rations, shifting may be termi- nated once the required number of bits have been acquired. dr output value (address phase) xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb dr output value (dat a read phase) xxxxxeb dddddddd dddddddd dddddddd dddddddd dr output value (d ata write phase) xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb table 39-19. memory_sized_access details (continued) instructions details table 39-20. memory_word_access details instructions details ir input value 10001 (0x11) ir output value peb01 dr size 35 bits dr input value (address phase) aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aar dr input value (data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxx dr input value (data write phase) dddddddd dddddddd dddddddd dddddddd xxx
1224 32117b?avr-03/11 at32uc3c 39.5.3.5 memory_block_access this instruction allows ac cess to the entire sab data area. up to 32 bits of data is accessed at a time, while the address is sequentially incr emented from the previously used address. in this mode, the sab a ddress, size, and access direction is not provided with each access. instead, the previous address is auto-incremente d depending on the specified size and the pre- vious operation repeated. the address must be set up in advance with memory_size_access or memory_word_acce ss. it is allowed, but not required, to shift data after shifting the address. this instruction is primarily intended to speed up large quantities of sequential word accesses. it is possible to use it also for byte and halfword accesses, but the overhead in this is case much larger as 32 bits must still be shifted for each access. the following sequence should be used: 1. use the memory_size_access or memory_word_access to read or write the first location. 2. return to run-test/idle. 3. select the ir scan path. 4. in capture-ir: the ir output value is latched into the shift register. 5. in shift-ir: the instruction register is shifted by the tck input. 6. return to run-test/idle. 7. select the dr scan path. t he address will now have increment ed by 1, 2, or 4 (corre- sponding to the next byte, halfword, or word location). 8. in shift-dr: for a read operation, scan out the contents of the next addressed location. for a write operation, scan in the new contents of the next addressed location. 9. go to update-dr. 10. if the block access is not complete, return to select-dr scan and repeat the access. 11. if the block access is complete, return to run-test/idle. for write operations, 32 data bits must be pr ovided, or the result will be undefined. for read operations, shifting may be terminated once the required number of bits have been acquired. dr output value (address phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xeb dr output value (data read phase) xeb dddddddd dddddddd dddddddd dddddddd dr output value (d ata write phase) xxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb table 39-20. memory_word_access details (continued) instructions details table 39-21. memory_block_access details instructions details ir input value 10010 (0x12) ir output value peb01 dr size 34 bits dr input value (data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xx
1225 32117b?avr-03/11 at32uc3c the overhead using block word access is 4 cycles per 32 bits of data, resulting in an 88% trans- fer efficiency, or 2.1 mbytes per second with a 20 mhz tck frequency. 39.5.3.6 cancel_access if a very slow memory location is accessed du ring a sab memory access, it could take a very long time until the busy bit is cleared, and the sab becomes ready for the next operation. the cancel_access instruction pr ovides a possibility to abort an ongoing transfer and report a timeout to the jtag master. when the cancel_access instruction is select ed, the current access will be terminated as soon as possible. there are no guarantees about how long this will take, as the hardware may not always be able to cancel the access immedi ately. the sab is ready to respond to a new command when the busy bit clears. starting in run-test/idl e, cancel_access is acce ssed in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. return to run-test/idle. 39.5.3.7 sync this instruction allows external debuggers and testers to measure the ratio between the external jtag clock and the internal system clock. the sync data register is a 16-bit counter that counts down to zero using the internal system clock. the busy bit stays high until the counter reaches zero. starting in run-test/idle, sync inst ruction is used in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. dr input value (data write phase) dddddddd dddddddd dddddddd dddddddd xx dr output value (data read phase) eb dddddddd dddddddd dddddddd dddddddd dr output value (data write phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb table 39-21. memory_block_access details (continued) instructions details table 39-22. cancel_access details instructions details ir input value 10011 (0x13) ir output value peb01 dr size 1 dr input value x dr output value 0
1226 32117b?avr-03/11 at32uc3c 6. scan in an 16-bit counter value. 7. go to update-dr and re-enter select-dr scan. 8. in shift-dr: scan out the busy bit, and until the busy bit clears goto 7. 9. calculate an approximation to the internal clock speed using the elapsed time and the counter value. 10. return to run-test/idle. the full 16-bit counter value must be provided when starting the synch operation, or the result will be undefined. when r eading status, shifting may be term inated once the required number of bits have been acquired. 39.5.3.8 avr_reset this instruction allows a debugger or tester to directly control separate reset domains inside the chip. the shift register contains one bit for each controllable reset domain. setting a bit to one resets that domain and holds it in reset. setting a bit to zero releases the reset for that domain. the avr_reset instruction can be used in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in shift-dr: scan in the value corresponding to the reset domains the jtag master wants to reset into the data register. 7. return to run-test/idle. 8. stay in run test idle for at least 10 tck clock cycles to let the reset propagate to the system. see the device specific document ation for the number of reset domains, and what these domains are. for any operation, all bits must be provided or th e result will be undefined. table 39-23. sync_access details instructions details ir input value 10111 (0x17) ir output value peb01 dr size 16 bits dr input value dddddddd dddddddd dr output value xxxxxxxx xxxxxxeb table 39-24. avr_reset details instructions details ir input value 01100 (0x0c) ir output value p0001
1227 32117b?avr-03/11 at32uc3c 39.5.3.9 chip_erase this instruction allows a programmer to completely erase all nonvolatile memories in a chip. this will also clear any security bits that are set, so the device can be accessed normally. in devices without non-volatile memories this instruction does nothing, and appears to complete immediately. the erasing of non-volatile memo ries starts as soon as the chi p_erase instruction is selected. the chip_erase instruction selects a 1 bit bypass data register. a chip erase operation should be performed as: 1. reset the system and stop the cpu from executing. 2. select the ir scan path. 3. in capture-ir: the ir output value is latched into the shift register. 4. in shift-ir: the instruction register is shifted by the tck input. 5. check the busy bit that was scanned out during shift-ir. if the busy bit was set goto 2. 6. return to run-test/idle. 39.5.3.10 halt this instruction allows a programmer to easily stop the cpu to ensure that it does not execute invalid code during programming. this instruction selects a 1-bit halt register. setting this bit to one resets the device and halts the cpu. setting this bit to zero resets the device and releases the cpu to run normally. the value shifted out from the data register is one if the cpu is halted. the halt instruction can be used in the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. dr size device specific. dr input value device specific. dr output value device specific. table 39-24. avr_reset details (continued) instructions details table 39-25. chip_erase details instructions details ir input value 01111 (0x0f) ir output value p0b01 where b is the busy bit. dr size 1 bit dr input value x dr output value 0
1228 32117b?avr-03/11 at32uc3c 6. in shift-dr: scan in the value 1 to halt the cpu, 0 to start cpu execution. 7. return to run-test/idle. table 39-26. halt details instructions details ir input value 11100 (0x1c) ir output value p0001 dr size 1 bit dr input value d dr output value d
1229 32117b?avr-03/11 at32uc3c 39.5.4 jtag data registers the following device specific registers can be selected as jtag scan chain depending on the instruction loaded in the jtag instruction register. additional registers exist, but are implicitly described in the functional description of the relevant instructions. 39.5.4.1 device identification register the device identification register contains a unique identifier for each product. the register is selected by the idcode instruction, which is the default instruction after a jtag reset. device specific id codes the different device configurations have different jtag id codes, as shown in table 39-27 . note that if the flash co ntroller is statically rese t, the id code will be undefined . msb lsb bit 31 28 27 12 11 1 0 device id revision part number manufacturer id 1 4 bits 16 bits 11 bits 1 bit revision this is a 4 bit number identifying the revision of the component. rev a = 0x0, b = 0x1, etc. part number the part number is a 16 bit code identifying the component. manufacturer id the manufacturer id is a 11 bit code identifying the manufacturer. the jtag manufacturer id for atmel is 0x01f. table 39-27. device and jtag id device name jtag id code (r is the revision number) at32uc3c0512c 0xr200003f at32uc3c0256c 0xr200103f at32uc3c0128c 0xr200203f at32uc3c064c 0xr200303f at32uc3c1512c 0xr200403f at32uc3c1256c 0xr200503f at32uc3c1128c 0xr200603f at32uc3c164c 0xr200703f at32uc3c2512c 0xr200803f at32uc3c2256c 0xr200903f at32uc3c2128c 0xr200a03f at32uc3c264c 0xr200b03f
1230 32117b?avr-03/11 at32uc3c 39.5.4.2 reset register the reset register is selected by the avr_reset instruction and co ntains one bit for each reset domain in the device. se tting each bit to one will keep that domain reset until the bit is cleared. 39.5.4.3 boundary--scan chain the boundary-scan chain has the c apability of driving an d observing the logic levels on the digi- tal i/o pins, as well as driving and observing the lo gic levels between the digital i/o pins and the internal logic. typically, output value, output enable, and input data are all available in the boundary-scan chain. the boundary-scan chain is described in the bsdl (boundary scan description language) file available at the atmel web site. bit 0 reset domain system system resets the whole chip, except the jtag itself.
1231 32117b?avr-03/11 at32uc3c 39.6 awire debug interface (aw) rev.: 2.3.0.1 39.6.1 features ? single pin debug system. ? half duplex asynchronous communication (uart compatible). ? full duplex mode for direct uart connection. ? compatible with jtag function ality, except boundary scan. ? failsafe packet-oriented protocol. ? read and write on-chip memory and program on -chip flash and fuses through sab interface. ? on-chip debug access through sab interface. ? asynchronous receiver or transmitter when the awire system is not used for debugging. 39.6.2 overview the awire debug interface (aw) offers a single pi n debug solution that is fully compatible with the functionality offered by the jtag interface, except boundary scan. this functionality includes memory access, programming capab ilities, and on-chip debug access. figure 39-8 on page 1232 shows how the aw is connected in a 32-bit avr device. the reset_n pin is used both as reset and debug pin. a specia l sequence on reset_n is needed to block the normal reset functionality and enable the aw. the service access bus (sab) interface cont ains address and data registers for the service access bus, which gives access to on-chip debug, programming, and other functions in the device. the sab offers several modes of access to the addre ss and data registers, as dis- cussed in section 39.6.6.8 . section 39.6.7 lists the supported awire commands and responses, with references to the description in this document. if the aw is not used for debugging, the awire ua rt can be used by the user to send or receive data with one stop bit, eight data bits, no parity bits, and one stop bit. this can be controlled through the awire user interface.
1232 32117b?avr-03/11 at32uc3c 39.6.3 block diagram figure 39-8. awire debug interface block diagram 39.6.4 i/o lines description 39.6.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. table 39-28. i/o lines description name description type data awire data multiplexed wit h the reset_n pin. input/output dataout awire data output in 2-pin mode. output uart reset filter external reset aw_enable reset_n baudrate detector rw sz addr data crc aw control aw user interface sab interface reset command power manager cpu halt command flash controller chip_erase command awire debug interface pb sab
1233 32117b?avr-03/11 at32uc3c 39.6.5.1 i/o lines the pin used by aw is multiple xed with the reset_n pi n. the reset function ality is the default function of this pin. to enable the awire func tionality on the reset_n pin the user must enable the aw either by sending the enable sequence over the reset_n pin from an external awire master or by enabling the awire user interface. in 2-pin mode data is received on the rese t_n line, but transmitted on the dataout line. after sending the 2_pin_mode command the dataout line is automatically enabled. all other peripheral functions on this pin is disabled. 39.6.5.2 power management when debugging through aw the system clocks are automatically turned on to allow debugging in sleep modes. 39.6.5.3 clocks the awire uart uses the internal 120 mhz rc oscillator (rc120m) as clock source for its operation. when enabling the aw the rc120m is automatically started. 39.6.6 functional description 39.6.6.1 awire communication protocol the aw is accessed through the reset_n pin shown in table 39-28 on page 1232 . the aw communicates through a uart operating at vari able baud rate (depending on a sync pattern) with one start bit, 8 data bits (lsb first), one stop bit, and no parity bits. the awire protocol is based upon command packets from an externalmaster and response packets from the slave (aw). the master always initiates communication and decides the baud rate. the packet contains a sync byte (0x55), a comm and/response byte, two length bytes (optional), a number of data bytes as defined in the length field (optional), and two crc bytes. if the com- mand/response has the most significant bit set, the command/response also carries the optional length and data fields. the crc field is not checked if the crc value transmitted is 0x0000. crc calculation table 39-29. awire packet format field number of bytes description comment optional sync 1 sync pattern (0x55). used by the receiver to set the baud rate clock. no command/ response 1 command from the master or response from the slave. when the most significant bit is set the command/response has a length field. a response has the next most significant bit set. a command does not have this bit set. no length 2 the number of bytes in the data field. ye s data length data according to command/ response. ye s crc 2 crc calculated with the fcs16 polynomial. crc value of 0x0000 makes the awire disregard the crc if the master does not support it. no
1234 32117b?avr-03/11 at32uc3c the crc is calculated from th e command/response, length, and data fields. the polynomial used is the fcs16 (or crc-16-ccit) in reve rse mode (0x8408) and the starting value is 0x0000. example command below is an example command from the master with additional data. figure 39-9. example command example response below is an example response from the slave with additional data. figure 39-10. example response avoiding drive contention when changing direction the awire debug protocol uses one dataline in both directions. to avoid both the master and the slave to drive this line when changing direction the aw has a built in guard time before it starts to drive the line. at reset this guard time is set to maximum (128 bit cycles), but can be lowered by the master upon command. the aw will release the line im mediately after the stop char acter has been transmitted. baud_rate_clk data_pin ... field sync(0x55) command(0x81) length(msb) length(lsb) ... data(msb) data(lsb) crc(msb) crc(lsb) baud_rate_clk data_pin ... field sync(0x55) response(0xc1) length(msb) length(lsb) ... data(msb) data(lsb) crc(msb) crc(lsb)
1235 32117b?avr-03/11 at32uc3c 39.6.6.2 during the direction change there can be a period when the line is not driven. the internal pullup of the reset_n pin keeps the signal stable when neither master or slave is actively driving the line. the reset_n pin normal reset functionality on the reset_n pin is disabled when using awire. however, the user can reset the system through the reset awire command. during awire operation the reset_n pin should not be conne cted to an external reset ci rcuitry, but disconnected via a switch or a jumper to avoid drive contention and speed problems. figure 39-11. reset circuitry and awire. 39.6.6.3 initializing the aw to enable aw, the user has to send a 0x55 patte rn with a baudrate of 1 khz on the reset_n pin. the aw is enabled after tr ansmitting this pattern and the us er can start transmitting com- mands. this pattern is not the sync pattern for the first command. after enabling the awire debug interface the halt bit is set automatically to prevent the system from running code after the interface is enabled. to make the cpu run again set halt to zero using the halt command. 39.6.6.4 disabling the aw to disable aw, the user can keep the reset_n pin low for 100 ms. this will disable the aw, return reset_n to its normal fu nction, and reset the device. an awire master can also disable awire by sending the disable command. after acking the command the aw will be disabled and rese t_n returns to its normal function. 39.6.6.5 resetting the aw the awire master can reset the aw slave by pulling the reset_n pin low for 20 ms. this is equivalent to disabling and then enabling aw. 39.6.6.6 2-pin mode to avoid using special hardware when using a normal uart device as awire master, the awire slave has a 2-pin mode where one pin is used as input and on pin is used as output. to enable this mode the 2_pin_mode command must be sent. after sending the command, all responses will be sent on the dataout pin instead of th e reset_n pin. commands are still received on the reset_n pin. reset_n aw debug interface jumper mcu power manager awire master connector board reset circuitry
1236 32117b?avr-03/11 at32uc3c 39.6.6.7 baud rate clock the communication speed is set by the master in the sync field of the command. the aw will use this to resynchronize its baud rate cloc k and reply on this frequency. the minimum fre- quency of the communication is 1 khz. the maximum frequency depends on the internal clock source for the aw (rc120m). the baud rate cl ock is generated by aw with the following formula: where is the baud rate frequency and is the frequency of the internal rc120m. tune is the value returned by the baud_rate response. to find the max frequency the user can issue the tune command to the aw to make it return the tune value. this value can be used to compute the . the maximum operational fre- quency ( ) is then: 39.6.6.8 service access bus the avr32 architecture offers a common interface for access to on-chip debug, programming, and test functions. these are mapped on a common bus called t he service acce ss bus (sab), which is linked to the awire through a bus mast er module, which also handles synchronization between the awire and sab clocks. for more information about the sab and a list of sab slaves see the service access bus chapter. sab clock when accessing the sab through the awire there are no limitations on baud rate frequency compared to chip frequency, although there must be an active system clock in order for the sab accesses to complete. if the system clock (clk_sys) is switched off in sleep mode, activity on the awire pin will restart the clk_sys automatica lly, without waking t he device from sleep. awire masters may optimize the transfer rate by adjusting the baud rate frequency in relation to the clk_sys. this ratio can be measur ed with the memory_speed_request command. when issuing the memory_speed_request comm and a counter value cv is returned. cv can be used to calculate the sab speed ( ) using this formula: sab address mode the service access bus uses 36 address bits to address memory or registers in any of the slaves on the bus. the bus supports sized accesses of bytes (8 bits), halfwords (16 bits), or words (32 bits). all accesses must be aligned to the size of th e access, i.e. halfword accesses must have the lowest address bit cleared, and word accesses must have the two lowest address bits cleared. f aw tune f br 8 ---------------------------- - = f br f aw f aw f brmax f brmax f aw 4 ------- = f sab f sab 3 f aw cv 3 ? ---------------- - =
1237 32117b?avr-03/11 at32uc3c two instructions exist to access the sab: memory_write and memory_read. these two instructions write and read words, halfwords, and bytes from the sab. busy reporting if the awire master, during a memory_wri te or a memory_read command, transmit another byte when the awire is still busy send ing the previous byte to the sab, the aw will respond with a memory_read_write_status error. see chapter section 39.6.8.5 for more details. the awire master should adjust its baudrate or delay between bytes when doing sab accesses to ensure that the sab is not overwhelmed with data. error reporting if a write is performed on a non-existing memory location the sab interface will respond with an error. if this happens, all further writes in this command will not be performed and the error and number of bytes written is reported in the memory_readwrite_status message from the aw after the write. if a read is performed on a non-existing memo ry location, the sab in terface will respond with an error. if this happens, the data bytes read after this event are not valid. the aw will include three extra bytes at the end of the transfer to indicate if the transfer was successful, or in the case of an error, how many valid bytes were received. 39.6.6.9 crc errors/nack response the aw will calculate a crc value when receiving the command, lengt h, and data fields of the command packets. if this value differs from the value from the crc field of the packet, the aw will reply with a nack response. otherwis e the command is carried out normally. an unknown command will be re plied with a nack response. in worst case a transmission error can happen in the length or command field of the packet. this can lead to the awire slave trying to receive a command with or without length (opposite of what the master intended) or receive an incorrect number of byte s. the awire slave will then either wait for more data when the master has finished or already have transmitted the nack response in congestion with the master. the master can implement a timeout on every com- mand and reset the slave if no response is returned after the timeout period has ended. 39.6.7 awire command summary the implemented awire commands are shown in the table below. the responses from the aw are listed in section 39.6.8 . table 39-30. awire command summary command instruction description 0x01 aya ?are you alive?. 0x02 jtag_id asks aw to return the jtag idcode. 0x03 status_request request a status message from the aw. 0x04 tune tell the aw to report the current baud rate. 0x05 memory_speed_request reports the speed difference between the awire control and the sab clock domains. 0x06 chip_erase erases the flash and all volatile memories.
1238 32117b?avr-03/11 at32uc3c all awire commands are described below, with a summary in table form. 39.6.7.1 aya this command asks the aw: ?are you aliv e?, where the aw should respond with an acknowledge. 39.6.7.2 jtag_id this command instructs the aw to output the jtag idcode in the following response. 0x07 disable disables the aw. 0x08 2_pin_mode enables the dataout pin and puts the awire in 2-pin mode, where all responses are sent on the dataout pin. 0x80 memory_write writes words, halfwords, or bytes to the sab. 0x81 memory_read reads words, halfwords, or bytes from the sab. 0x82 halt issues a halt command to the device. 0x83 reset issues a reset to the reset controller. 0x84 set_guard_time sets the guard time for the aw. table 39-30. awire command summary command instruction description table 39-31. command/response description notation command/response description command/response value shows the command/response value to put into the command/response field of the packet. additional data shows the format of the optional data field if applicable. possible responses shows the possi ble responses for this command. table 39-32. aya details command details command value 0x01 additional data n/a possible responses 0x40: ack ( section 39.6.8.1 ) 0x41: nack ( section 39.6.8.2 ) table 39-33. jtag_id details command details command value 0x02 additional data n/a possible responses 0xc0: idcode ( section 39.6.8.3 ) 0x41: nack ( section 39.6.8.2 )
1239 32117b?avr-03/11 at32uc3c 39.6.7.3 status_request asks the aw for a status message. 39.6.7.4 tune asks the aw for the current baud rate counter value. 39.6.7.5 memory_speed_request asks the aw for the relative speed between the awire clo ck (rc120m) and t he sab interface. 39.6.7.6 chip_erase this instruction allows a programmer to completely erase all nonvolatile memories in the chip. this will also clear any security bits that are set, so the device can be accessed normally. the command is acked immediately, but the status of the command can be monitored by checking the chip erase ongoing bit in the status bytes received after the status_request command. table 39-34. status_request details command details command value 0x03 additional data n/a possible responses 0xc4: status_info ( section 39.6.8.7 ) 0x41: nack ( section 39.6.8.2 ) table 39-35. tune details command details command value 0x04 additional data n/a possible responses 0xc3: baud_rate ( section 39.6.8.6 ) 0x41: nack ( section 39.6.8.2 ) table 39-36. memory_speed_request details command details command value 0x05 additional data n/a possible responses 0xc5: memory_speed ( section 39.6.8.8 ) 0x41: nack ( section 39.6.8.2 ) table 39-37. chip_erase details command details command value 0x06 additional data n/a possible responses 0x40: ack ( section 39.6.8.1 ) 0x41: nack ( section 39.6.8.2 )
1240 32117b?avr-03/11 at32uc3c 39.6.7.7 disable disables the aw. the aw will re spond with an ack response and then disable itself. 39.6.7.8 2_pin_mode enables the dataout pin as an ou tput pin. all respons es sent from the awire slave will be sent on this pin, instead of the reset_n pin, starting with the ack for the 2_pin_mode command. 39.6.7.9 memory_write this command enables programming of memo ry/writing to registers on the sab. the memory_write command allows words, halfwords, and bytes to be programmed to a contin- uous sequence of addresses in one operation. before transferring the data, the user must supply: 1. the number of data bytes to write + 5 (size and starting address) in the length field. 2. the size of the transfer: words, halfwords, or bytes. 3. the starting address of the transfer. the 4 msb of the 36 bit sab address are submitted to gether with the size fi eld (2 bits). then fol- lows the 4 remaining address bytes and finally the data bytes. the size of the transfer is specified using the values from the following table: below is an example write command: 1. 0x55 (sync) 2. 0x80 (command) 3. 0x00 (length msb) table 39-38. disable details command details command value 0x07 additional data n/a possible responses 0x40: ack ( section 39.6.8.1 ) 0x41: nack ( section 39.6.8.2 ) table 39-39. disable details command details command value 0x07 additional data n/a possible responses 0x40: ack ( section 39.6.8.1 ) 0x41: nack ( section 39.6.8.2 ) table 39-40. size field decoding size field description 00 byte transfer 01 halfword transfer 10 word transfer 11 reserved
1241 32117b?avr-03/11 at32uc3c 4. 0x09 (length lsb) 5. 0x25 (size and address msb, the two msb of this byte are unused and set to zero) 6. 0x00 7. 0x00 8. 0x00 9. 0x04 (address lsb) 10. 0xca 11. 0xfe 12. 0xba 13. 0xbe 14. 0xxx (crc msb) 15. 0xxx (crc lsb) the length field is set to 0x0009 because there are 9 bytes of additional data: 5 address and size bytes and 4 bytes of data. the address and size field indicates that words should be written to address 0x5000 00004. the data written to 0x500000004 is 0xcafebabe. 39.6.7.10 memory_read this command enables reading of memory/registers on the service access bus (sab). the memory_read command allows words, halfwords, and bytes to be read from a continuous sequence of addresses in one operation. the user must supply: 1. the size of the data field: 7 (size and starting address + read length indicator) in the length field. 2. the size of the transfer: words, halfwords, or bytes. 3. the starting address of the transfer. 4. the number of bytes to read (max 65532). the 4 msb of the 36 bit sab addre ss are submitted together with th e size field (2 bits). the 4 remaining address bytes are submitted before the number of bytes to read. the size of the transfer is specified using the values from the following table: below is an example read command: table 39-41. memory_write details command details command value 0x80 additional data size, address and data possible responses 0xc2: memory_readwrite_status ( section 39.6.8.5 ) 0x41: nack ( section 39.6.8.2 ) table 39-42. size field decoding size field description 00 byte transfer 01 halfword transfer 10 word transfer 11 reserved
1242 32117b?avr-03/11 at32uc3c 1. 0x55 (sync) 2. 0x81 (command) 3. 0x00 (length msb) 4. 0x07 (length lsb) 5. 0x25 (size and address msb, the two msb of this byte are unused and set to zero) 6. 0x00 7. 0x00 8. 0x00 9. 0x04 (address lsb) 10. 0x00 11. 0x04 12. 0xxx (crc msb) 13. 0xxx (crc lsb) the length field is set to 0x0007 because there ar e 7 bytes of additional data: 5 bytes of address and size and 2 bytes with the number of bytes to read. the address and size field indicates one word (four bytes) should be read from address 0x500000004. 39.6.7.11 halt this command tells the cpu to halt code execution for safe programming. if the cpu is not halted during programming it can start executing partially loaded programs. to halt the proces- sor, the awire master should send 0x01 in the data field of the command. after programming the halting can be released by sending 0x00 in the data field of the command. 39.6.7.12 reset this command resets different domains in the part. the awire master sends a byte with the reset value. each bit in the reset value byte corresponds to a reset domain in the chip. if a bit is set the reset is activated and if a bit is not set the reset is released. the number of reset domains table 39-43. memory_read details command details command value 0x81 additional data size, address and length possible responses 0xc1: memdata ( section 39.6.8.4 ) 0xc2: memory_readwrite_status ( section 39.6.8.5 ) 0x41: nack ( section 39.6.8.2 ) table 39-44. halt details command details command value 0x82 additional data 0x01 to halt the cpu 0x00 to release the halt and reset the device. possible responses 0x40: ack ( section 39.6.8.1 ) 0x41: nack ( section 39.6.8.2 )
1243 32117b?avr-03/11 at32uc3c and their destinations are identical to the resets described in the jtag data registers chapter under reset register. 39.6.7.13 set_guard_time sets the guard time value in the aw, i.e. how long the aw will wait before starting its transfer after the master has finished. the guard time can be either 0x00 (128 bit lengths), 0x01 (16 bit lengths), 0x2 (4 bit lengths) or 0x3 (1 bit length). 39.6.8 awire response summary the implemented awire responses are shown in the table below. table 39-45. reset details command details command value 0x83 additional data reset value for each reset do main. the number of reset domains is part specific. possible responses 0x40: ack ( section 39.6.8.1 ) 0x41: nack ( section 39.6.8.2 ) table 39-46. set_guard_time details command details command value 0x84 additional data guard time possible responses 0x40: ack ( section 39.6.8.1 ) 0x41: nack ( section 39.6.8.2 ) table 39-47. awire response summary response instruction description 0x40 ack acknowledge. 0x41 nack not acknowledge. sent after crc errors and after unknown commands. 0xc0 idcode the jtag idcode. 0xc1 memdata values read from memory. 0xc2 memory_readwrite_status status after a memory_write or a memory_read command. ok, busy, error. 0xc3 baud_rate the current baudrate. 0xc4 status_info status information. 0xc5 memory_speed sab to awire speed information.
1244 32117b?avr-03/11 at32uc3c 39.6.8.1 ack the aw has received the command successfully and performed the operation. 39.6.8.2 nack the aw has received the command, but got a crc mismatch. 39.6.8.3 idcode the jtag idcode for this device. 39.6.8.4 memdata the data read from the address specified by the memory_read command. the last 3 bytes are status bytes from the read. the first status byte is the status of the command described in the table below. the last 2 bytes are the number of remaining data bytes to be sent in the data field of the packet when the error occurred. if the read was not successful all data bytes after the failure are undefined. a su ccessful word read (4 bytes) will look like this: 1. 0x55 (sync) 2. 0xc1 (command) 3. 0x00 (length msb) 4. 0x07 (length lsb) 5. 0xca (data msb) 6. 0xfe 7. 0xba 8. 0xbe (data lsb) 9. 0x00 (status byte) 10. 0x00 (bytes remaining msb) 11. 0x00 (bytes remaining lsb) 12. 0xxx (crc msb) 13. 0xxx (crc lsb) the status is 0x00 and all data read are valid. an unsuccessful four byte read can look like this: table 39-48. ack details response details response value 0x40 additional data n/a table 39-49. nack details response details response value 0x41 additional data n/a table 39-50. idcode details response details response value 0xc0 additional data jtag idcode
1245 32117b?avr-03/11 at32uc3c 1. 0x55 (sync) 2. 0xc1 (command) 3. 0x00 (length msb) 4. 0x07 (length lsb) 5. 0xca (data msb) 6. 0xfe 7. 0xxx (an error has occurred. data read is undefined. 5 bytes remaining of the data field) 8. 0xxx (more undefined data) 9. 0x02 (status byte) 10. 0x00 (bytes remaining msb) 11. 0x05 (bytes remaining lsb) 12. 0xxx (crc msb) 13. 0xxx (crc lsb) the error occurred after reading 2 bytes on the sab. the rest of the bytes read are undefined. the status byte indicates the error and the bytes remaining indicates how many bytes were remaining to be sent of the data field of the packet when the error occurred. 39.6.8.5 memory_readwrite_status after a memory_write command this response is sent by aw. the response can also be sent after a memory_read command if aw encountered an error when receiving the address. the response contains 3 bytes, where t he first is the status of the command and the 2 next contains the byte count when the first erro r occurred. the first byte is encoded this way: table 39-51. memdata status byte status byte description 0x00 read successful 0x01 sab busy 0x02 bus error (wrong address) other reserved table 39-52. memdata details response details response value 0xc1 additional data data read, status byte, and byte count (2 bytes) table 39-53. memory_readwrite_status status byte status byte description 0x00 write successful 0x01 sab busy 0x02 bus error (wrong address) other reserved
1246 32117b?avr-03/11 at32uc3c 39.6.8.6 baud_rate the current baud rate in the aw. see section 39.6.6.7 for more details. 39.6.8.7 status_info a status message from aw. 39.6.8.8 memory_speed counts the number of rc120m clock cycles it takes to sync one message to the sab interface and back again. the sab clock speed ( ) can be calculated using the following formula: table 39-54. memory_readwrite_status details response details response value 0xc2 additional data status byte and byte count (2 bytes) table 39-55. baud_rate details response details response value 0xc3 additional data baud rate table 39-56. status_info contents bit number name description 15-9 reserved 8protected the protection bit in the in ternal flash is set. sab acce ss is restricted. this bit will read as one during reset. 7 sab busy the sab bus is busy with a previous transf er. this could indi cate that the cpu is running on a very slow clock, the cpu clock has stopped for some reason or that the part is in constant reset. 6 chip erase ongoing the chip erase operation has not finished. 5 cpu halted this bit will be set if the cpu is halted. this bit will read as zero during reset. 4-1 reserved 0 reset status this bit will be set if aw has reset the cpu using the reset command. table 39-57. status_info details response details response value 0xc4 additional data 2 status bytes f sab f sab 3 f aw cv 3 ? ---------------- - =
1247 32117b?avr-03/11 at32uc3c 39.6.9 security restrictions when the security fuse in the flash is programmed, the following awire commands are limited: ? memory_write ? memory_read unlimited access to these instructions is restored when the security fuse is erased by the chip_erase awire command. note that the security bit will read as programmed and block these instructions also if the flash controller is statically reset. table 39-58. memory_speed details response details response value 0xc5 additional data clock cycle count (ms)
1248 32117b?avr-03/11 at32uc3c 39.7 module configuration the bit mapping of the peripheral debug register (pdbg) is described in the following table. please refer to the on-chip debug chapter in the avr32uc technical reference manual for details. table 39-59. bit mapping of the peripheral debug register (pdbg) bit peripheral 0 ast 1wdt 2canif 3 qdec0 4 qdec1 5adcifa 6acifa0 7acifa1 8dacifb0 9dacifb1 10 pevc 11-31 reserved
1249 32117b?avr-03/11 at32uc3c 40. electrical characteristics 40.1 absolute maximum ratings* notes: 1. v vdd corresponds to either v vddio1 , v vddio2 , v vddio3 , or v vddana , depending on the supply for the pin. refer to section 3-1 on page 11 for details. 40.2 supply characteristics the following characteristics are applicable to the operating temperature range: t a = -40c to 85c, unless otherwise spec- ified and are valid for a junction temperature up to t j = 100c. please refer to section 6. ?supply and startup considerations? on page 46 . operating temperature..................................... -40c to +85c *notice: stresses beyond those listed under ?absolute maximum ratings? may cause permanent dam- age to the device. this is a stress rating only and functional operation of the device at these or other conditions beyond those indicated in the operational sections of this specification is not implied. exposure to absolute maximum rating conditions for extended periods may affect device reliability. storage temperature...................................... -60c to +150c voltage on any pin except dm/dp/vbus with respect to ground ............................ -0.3v to v vdd (1) +0.3v voltage on dm/dp with respect to ground.........-0.3v to +3.6v voltage on vbus with respect to ground...........-0.3v to +5.5v maximum operating voltage (vddin_5) ........................... 5.5v maximum operating voltage (vddio1, vddio2, vddio3, vddana).......................................................................... 5.5v maximum operating voltage (vdd in_33) ............ ............. 3.6v total dc output current on all i/o pins- vddio1 ......... 120 ma total dc output current on all i/o pins- vddio2 ......... 120 ma total dc output current on all i/o pins- vddio3 ......... 120 ma total dc output current on all i/o pins- vddana........ 120 ma table 40-1. supply characteristics symbol parameter condition voltage min max unit v vddin_5 dc supply internal regulators 3v range 3.0 3.6 v 5v range 4.5 5.5 v vddin_33 dc supply usb i/o only in 3v range 3.0 3.6 v v vddana dc supply peripheral i/o and analog part 3v range 3.0 3.6 v 5v range 4.5 5.5 v vddio1 v vddio2 v vddio2 dc supply peripheral i/o 3v range 3.0 3.6 v 5v range 4.5 5.5
1250 32117b?avr-03/11 at32uc3c 40.3 maximum clock frequencies these parameters are given in the following conditions: ?v vddcore > 1.85v ? temperature = -40c to 85c note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. 40.4 power consumption the values in table 40-4 are measured values of power consumption under the following condi- tions, except where noted: ? operating conditions core supply ( figure 40-1 ) ?v vddin_5 = v vddin_33 = 3.3v ?v vddcore = 1.85v, supplied by the internal regulator ?v vddio1 = v vddio2 = v vddio3 = 3.3v ?v vddana = 3.3v table 40-2. supply rise rates and order symbol parameter rise rate min max comment v vddin_5 dc supply internal 3.3v regulator 0.01 v/ms 1.25 v/us v vddin_33 dc supply internal 1.8v regulator 0.01 v/ms 1.25 v/us v vddio1 v vddio2 v vddio3 dc supply peripheral i/o 0.01 v/ms 1.25 v/us rise after or at the same time as vddin_5, vddin_33 v vddana dc supply peripheral i/o and analog part 0.01 v/ms 1.25 v/us rise after or at the same time as vddin_5, vddin_33 table 40-3. clock frequencies symbol parameter conditions min max units f cpu cpu clock frequency 66 mhz f pba pba clock frequency 66 mhz f pbb pbb clock frequency 66 mhz f pbc pbc clock frequency 66 mhz f gclk0 gclk0 clock frequency generic clock for usbc 50 (1) mhz f gclk1 gclk1 clock frequency generic clock for canif 66 (1) mhz f gclk2 gclk2 clock frequency generic clock for ast 80 (1) mhz f gclk4 gclk4 clock frequency generic clock for pwm 133 (1) mhz f gclk11 gclk11 clock frequency generic clock for iisc 50 (1) mhz
1251 32117b?avr-03/11 at32uc3c ? internal 3.3v regulator is off ?t a = 25 c ? i/os are configured as inputs, with internal pull-up enabled. ? oscillators ? osc0/1 (crystal oscillator) stopped ? osc32k (32khz crystal oscillator) stopped ? pll0 running ? pll1 stopped ? clocks ? external clock on xin0 as main clock source ( 10mhz ) ? cpu, hsb, and pbb clocks undivided ? pba, pbc clock divided by 4 ? all peripheral clocks running note: 1. these numbers are valid for the measured condition only and must not be extrapolated to other frequencies. table 40-4. power consumption for different operating modes mode conditions measured on consumption typ unit active (1) cpu running a recursive fibonacci algorithm amp 512 a/mhz idle (1) 258 frozen (1) 106 standby (1) 48 stop 73 a deepstop 43 static osc32k and ast running 32 ast and osc32k stopped 31
1252 32117b?avr-03/11 at32uc3c figure 40-1. measurement schematic 40.4.1 peripheral power consumption the values in table 40-5 are measured values of power consumption under the following conditions. ? operating conditions core supply ( figure 40-1 ) ?v vddin_5 = v ddin_33 = 3.3v ?v vddcore = 1.85v , supplied by the internal regulator ?v vddio1 = v vddio2 = v vddio3 = 3.3v ?v vddana = 3.3v ? internal 3.3v regulator is off. ?t a = 25 c ? i/os are configured as inputs, with internal pull-up enabled. ? oscillators ? osc0/1 (crystal oscillator) stopped ? osc32k (32khz crystal oscillator) stopped ? pll0 running amp vddana vddio vddin_5 vddcore gndcore gndpll vddin_33
1253 32117b?avr-03/11 at32uc3c ? pll1 stopped ? clocks ? external clock on xin0 as main clock source. ? cpu, hsb, and pb clocks undivided consumption active is the added current cons umption when the module clock is turned on and when the module is doing a typical set of operations. notes: 1. includes the current consumption on vddana. 2. these numbers are valid for the measured condi tion only and must not be extrapolated to other frequencies. table 40-5. typical current consumption by peripheral (2) peripheral typ consumption active unit acifa (1) 3 a/mhz adcifa (1) 7 ast 3 canif 25 dacifb (1) 3 ebi 23 eic 0.5 freqm 0.5 gpio 37 intc 3 mdma 4 pdca 24 pevc 15 pwm 40 qdec 3 sau 3 sdramc 2 smc 9 spi 5 tc 8 twim 2 twis 2 usart 10 usbc 5 wdt 2
1254 32117b?avr-03/11 at32uc3c 40.5 i/o pin c haracteristics table 40-6. normal i/o pin characteristics (1) symbol parameter condi tion min typ max units r pullup pull-up resistance 5 16 kohm r pulldown pull-down resistance 2 16 kohm v il input low-level voltage v vdd = 3v 0.8 v v vdd = 4.5v 1.3 v ih input high-level voltage v vdd = 3.6v 2.0 v v vdd = 5.5v 3.0 v ol output low-level voltage i ol = -3.5ma, pin drive x1 (2) 0.45 v i ol = -7ma, pin drive x2 (2) i ol = -14ma, pin drive x4 (2) v oh output high-level voltage i oh = 3.5ma, pin drive x1 (2) v vdd - 0.8 v i oh = 7ma, pin drive x2 (2) i oh = 14ma, pin drive x4 (2) f max output frequency (3) v vdd = 3.0v load = 10pf, pin drive x1 (2) 35 mhz load = 10pf, pin drive x2 (2) 55 load = 10pf, pin drive x4 (2) 70 load = 30pf, pin drive x1 (2) 15 load = 30pf, pin drive x2 (2) 30 load = 30pf, pin drive x4 (2) 45 v vdd =4.5v load = 10pf, pin drive x1 (2) 50 load = 10pf, pin drive x2 (2) 80 load = 10pf, pin drive x4 (2) 95 load = 30pf, pin drive x1 (2) 25 load = 30pf, pin drive x2 (2) 40 load = 30pf, pin drive x4 (2) 65
1255 32117b?avr-03/11 at32uc3c note: 1. v vdd corresponds to either v vddio1 , v vddio2 , v vddio3 , or v vddana , depending on the supply for the pin. refer to section 3-1 on page 11 for details. 2. drive x1 capability pins are: pb00, pb01, pb02, pb03, pb 30, pb31, pc02, pc03, pc04, pc05, pc06, pc07 - drive x2 /x4 capability pins are: pb06, pb21, pb26, pd02, pd06, pd13 - drive x1/x2 capability pins are the remaining pa, pb, pc, pd pins. the drive strength is programmable through odcr0, odcr0s, odcr0c, odcr0t registers of gpio. 3. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. t rise rise time (3) v vdd = 3.0v load = 10pf, pin drive x1 (2) 7.7 ns load = 10pf, pin drive x2 (2) 3.4 load = 10pf, pin drive x4 (2) 1.9 load = 30pf, pin drive x1 (2) 16 load = 30pf, pin drive x2 (2) 7.5 load = 30pf, pin drive x4 (2) 3.8 v vdd = 4.5v load = 10pf, pin drive x1 (2) 5.3 load = 10pf, pin drive x2 (2) 2.4 load = 10pf, pin drive x4 (2) 1.3 load = 30pf, pin drive x1 (2) 11.1 load = 30pf, pin drive x2 (2) 5.2 load = 30pf, pin drive x4 (2) 2.7 t fall fall time (3) v vdd = 3.0v load = 10pf, pin drive x1 (2) 7.6 ns load = 10pf, pin drive x2 (2) 3.5 load = 10pf, pin drive x4 (2) 1.9 load = 30pf, pin drive x1 (2) 15.8 load = 30pf, pin drive x2 (2) 7.3 load = 30pf, pin drive x4 (2) 3.8 v vdd = 4.5v load = 10pf, pin drive x1 (2) 5.2 load = 10pf, pin drive x2 (2) 2.4 load = 10pf, pin drive x4 (2) 1.4 load = 30pf, pin drive x1 (2) 10.9 load = 30pf, pin drive x2 (2) 5.1 load = 30pf, pin drive x4 (2) 2.7 i leak input leakage current pull-up resistors disabled 1.0 a c in input capacitance pa00-pa29, pb00-pb31, pc00-pc01, pc08-pc31, pd00-pd30 7.5 pf pc02, pc03, pc04, pc05, pc06, pc07 2 table 40-6. normal i/o pin characteristics (1) symbol parameter condi tion min typ max units
1256 32117b?avr-03/11 at32uc3c 40.6 oscillator characteristics 40.6.1 oscillator (osc0 and osc1) characteristics 40.6.1.1 digital clock characteristics the following table describes the characteristics for the oscillator when a digital clock is applied on xin0 or xin1. 40.6.1.2 crystal oscillator characteristics the following table describes the characteristics for the oscillator when a crystal is connected between xin and xout as shown in figure 40-2 . the user must choose a crystal oscillator where the crystal load capacitance c l is within the range given in the table. the exact value of c l can be found in the crystal datasheet. the capacitance of the external capacitors (c lext ) can then be computed as follows: where c pcb is the capacitance of the pcb and c i is the internal equivalent load capacitance. figure 40-2. oscillator connection table 40-7. digital clock ch aracteristics symbol parameter conditions min typ max units f cpxin xin clock frequency 50 mhz t cpxin xin clock period 20 ns t chxin xin clock high half-priod 0.4 x t cpxin 0.6 x t cpxin ns t clxin xin clock low half-priod 0.4 x t cpxin 0.6 x t cpxin ns c in xin input capacitance 2 pf c lext 2c l c i ? () c pcb ? = xin xout c lext c lext c i c l uc3c
1257 32117b?avr-03/11 at32uc3c notes: 1. please refer to th e scif chapter for details. 40.6.2 32khz crystal oscillator (osc32k) characteristics 40.6.2.1 digital clock characteristics the following table describes the characteristics for the oscillator when a digital clock is applied on xin32. 40.6.2.2 crystal oscillator characteristics figure 40-2 and the equation above also applies to the 32khz oscillator connection. the user must choose a crystal oscillator where the crystal load capacitance c l is within the range given in the table. the exact value of c l can then be found in the crystal datasheet.. table 40-8. crystal oscillator characteristics symbol parameter conditions min typ max unit f out crystal oscillator frequency 0.4 20 mhz c i internal equivalent load capacitance 1.7 pf t startup startup time f out = 8mhz scif.oscctrl.gain = 1 (1) 975 us f out = 16mhz scif.oscctrl.gain = 2 (1) 1100 us table 40-9. digital 32khz clock characteristics symbol parameter conditions min typ max units f cpxin xin32 clock frequency 32.768 5000 khz t cpxin xin32 clock period 200 ns t chxin xin32 clock high half-priod 0.4 x t cpxin 0.6 x t cpxin ns t clxin xin32 clock low half-priod 0.4 x t cpxin 0.6 x t cpxin ns c in xin32 input capacitance 2 pf table 40-10. 32 khz crystal oscillator characteristics symbol parameter conditions min typ max unit f out crystal oscillator frequency 32 768 hz t startup startup time r s = 50 kohm, c l = 12.5pf 2 s c l crystal load capacitance 6 15 pf c i internal equivalent load capacitance 1.4 pf
1258 32117b?avr-03/11 at32uc3c 40.6.3 phase lock loop (pll0 and pll1) characteristics 40.6.4 120mhz rc oscillator (rc120m) characteristics note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. 40.6.5 system rc oscillator (rcsys) characteristics 40.6.6 8mhz/1mhz rc oscillator (rc8m) characteristics notes: 1. please refer to th e scif chapter for details. table 40-11. pll characteristics symbol parameter conditions min typ max unit f vco output frequency 80 240 mhz f in input frequency 4 16 mhz i pll current consumption active mode, f vco = 80mhz 250 a active mode, f vco = 240mhz 600 t startup startup time, from enabling the pll until the pll is locked wide bandwidth mode disabled 15 s wide bandwidth mode enabled 45 table 40-12. internal 120mhz rc oscillator characteristics symbol parameter conditions min typ max unit f out output frequency (1) 88 120 152 mhz i rc120m current consumption 1.85 ma t startup startup time 3s table 40-13. system rc oscillator characteristics symbol parameter conditions min typ max unit f out output frequency calibrated at t a = 85c 110 115.2 120 khz t a = 25c 105 109 115 t a = -40c 100 104 108 table 40-14. 8mhz/1mhz rc oscilla tor characteristics symbol parameter conditions min typ max unit f out output frequency scif.rccr8.freqmode = 0 (1) 7.6 8 8.4 mhz scif.rccr8.freqmode = 1 (1) 0.955 1 1.045 t startup startup time 20 s
1259 32117b?avr-03/11 at32uc3c 40.7 flash characteristics table 40-15 gives the device maximum operating frequency depending on the number of flash wait states. the fsw bit in the flashc fsr regist er controls the number of wait states used when accessing the flash memory. table 40-15. maximum operating frequency flash wait states read mode maximum operating frequency 0 1 cycle 33mhz 1 2 cycles 66mhz table 40-16. flash characteristics symbol parameter conditions min typ max unit t fpp page programming time f clk_hsb = 66mhz 4.3 ms t fpe page erase time 4.3 t ffp fuse programming time 0.6 t fea full chip erase time (ea) 4.9 t fce jtag chip erase time (chip_erase) f clk_hsb = 115khz 640 table 40-17. flash endurance and data retention symbol parameter condit ions min typ max unit n farray array endurance (write/page) 100k cycles n ffuse general purpose fuses endu rance (write/bit) 1k cycles t ret data retention 15 years
1260 32117b?avr-03/11 at32uc3c 40.8 analog characteristics 40.8.1 1.8v voltage regulator characteristics 40.8.2 3.3v voltage regulator characteristics table 40-18. 1.8v voltage regulator electrical characteristics symbol parameter condition min typ max units v vddin_5 input voltage range 5v range 4.5 5.5 v 3v range 3.0 3.6 v vddcore output voltage, calibrated value 1.85 v v accuracy output voltage accuracy i out = 0.1ma to 100ma, v vddin _5 > 3v 5.8 % i out dc output current 80 ma i vreg static current of regulator low power mode 34 a table 40-19. decoupling requirements symbol parameter condition typ techno. units c in1 input regulator capacitor 1 1 npo nf c in2 input regulator capacitor 2 4.7 x7r uf c out1 output regulator capacitor 1 470 npo pf c out2 output regulator capacitor 2 2.2 x7r uf table 40-20. 3.3v voltage regulator electrical characteristics symbol parameter condition min typ max units v vddin_5 input voltage range 4.5 5.5 v v vddin_33 output voltage, calibrated value 3.4 v output voltage accuracy i out = 0.1ma to 40ma, v vddin > 4.5v 3.3 % i out dc output current 35 ma i vreg static current of regulator low power mode 45 a
1261 32117b?avr-03/11 at32uc3c 40.8.3 1.8v brown out detector (bod18) characteristics the values in table 40-21 describe the values of the bo d.level in the scif module. 40.8.4 3.3v brown out detector (bod33) characteristics the values in table 40-23 describe the values of the bod33. level field in the scif module. table 40-21. bodlevel values bodlevel value param eter min max units 0 1.38 1.52 v 20 1.44 1.58 26 threshold at power-up sequence 1.48 1.66 28 1.51 1.68 32 1.55 1.73 36 1.59 1.79 40 1.64 1.83 table 40-23. bod33.level values bod33.level value par ameter min max units 17 2.26 2.51 v 22 2.33 2.63 27 2.44 2.72 31 threshold at power-up sequence 2.50 2.80 33 2.54 2.84 39 2.66 2.95 44 2.74 3.06 49 2.84 3.16 53 2.91 3.24
1262 32117b?avr-03/11 at32uc3c 40.8.5 5v brown out detector (bod50) characteristics the values in table 40-25 describe the values of the bod50. level field in the scif module. table 40-25. bod50.level values bod50.level value par ameter min max units 16 3.31 3.62 v 25 3.54 3.88 35 3.82 4.16 44 4.05 4.43 53 4.30 4.69 61 4.52 4.92
1263 32117b?avr-03/11 at32uc3c 40.8.6 analog to digital converter (adc) and sample and hold (s/h) characteristics table 40-27. adc and s/h characteristics symbol parameter conditions min typ max units f adc adc clock frequency 12-bit resolution mode, v vddana = 3v 1.2 mhz 10-bit resolution mode, v vddana = 3v 1.6 8-bit resolution mode, v vddana = 3v 2.2 12-bit resolution mode, v vddana = 4.5v 1.5 10-bit resolution mode, v vddana = 4.5v 2 8-bit resolution mode, v vddana = 4.5v 2.4 t startup startup time adc cold start-up 1 ms adc hot start-up 24 adc clock cycles t conv conversion time (latency) (adcifa.seqcfgn.sres)/2 + 2, adcifa.cfg.shd = 1 68 adc clock cycles (adcifa.seqcfgn.sres)/2 + 3, adcifa.cfg.shd = 0 79 throughput rate 12-bit resolution, adc clock = 1.2 mhz, v vddana = 3v 1.2 msps 10-bit resolution, adc clock = 1.6 mhz, v vddana = 3v 1.6 12-bit resolution, adc clock = 1.5 mhz, v vddana = 4.5v 1.5 10-bit resolution, adc clock = 2 mhz, v vddana = 4.5v 2 table 40-28. adc reference voltage symbol parameter conditions min typ max units v adcref0 adcref0 input voltage range 5v range 1 3.5 v 3v range 1 v vddana -0.7 v adcref1 adcref1 input voltage range 5v range 1 3.5 v 3v range 1 v vddana -0.7 internal 1v reference 1.0 v internal 0.6*vddana reference 0.6*v vddana v table 40-29. adc decoupling requirements symbol parameter conditions min typ max units units c adcrefpn adcrefp-adcrefn capacitance 100 nf
1264 32117b?avr-03/11 at32uc3c figure 40-3. adc input note: 1. the measures are done without any i/o activity on vddana/gndana power domain. table 40-30. adc inputs symbol parameter conditions min typ max units v adcinn adc input voltage range 0 v vddana v c onchip internal capacitance adc used without s/h 5 pf adc used with s/h 4 r onchip switch resistance adc used without s/h 5.1 k adc used with s/h 4.6 c source v in r source adcin r onchip uc3c c onchip table 40-31. adc transfer characteristics 12-bit resolution mode (1) symbol parameter conditions min typ max units res resolution differential mode, v vddana = 3v, v adcref0 = 1v, adcfia.seqcfgn.sres = 0 12 bit inl integral non-linearity 2.5 lsb dnl differential non-linearity 1 lsb offset error -5 5 mv gain error -25 0 mv res resolution differential mode, v vddana = 5v, v adcref0 = 3v, adcfia.seqcfgn.sres = 0 12 bit inl integral non-linearity 3 lsb dnl differential non-linearity 1.2 lsb offset error -30 30 mv gain error -25 0 mv
1265 32117b?avr-03/11 at32uc3c note: 1. the measures are done without any i/o activity on vddana/gndana power domain. note: 1. the measures are done without any i/o activity on vddana/gndana power domain. table 40-32. adc transfer characteristics 10-bit resolution mode (1) symbol parameter conditions min typ max units res resolution differential mode, v vddana = 3v, v adcref0 = 1v, adcfia.seqcfgn.sres = 1 10 bit inl integral non-linearity 0.7 lsb dnl differential non-linearity 0.25 lsb offset error -5 5 mv gain error -25 0 mv res resolution differential mode, v vddana = 5v, v adcref0 = 3v, adcfia.seqcfgn.sres = 1 10 bit inl integral non-linearity 0.8 lsb dnl differential non-linearity 0.3 lsb offset error -30 30 mv gain error -25 0 mv table 40-33. adc transfer characteristics 8-bit resolution mode (1) symbol parameter conditions min typ max units res resolution differential mode, v vddana = 3v, v adcref0 = 1v, adcfia.seqcfgn.sres = 2 8bit inl integral non-linearity 0.4 lsb dnl differential non-linearity 0.2 lsb offset error -5 5 mv gain error -25 0 mv res resolution differential mode, v vddana = 5v, v adcref0 = 3v, adcfia.seqcfgn.sres = 2 8bit inl integral non-linearity 0.4 lsb dnl differential non-linearity 0.2 lsb offset error -5 5 mv gain error -25 0 mv table 40-34. adc and s/h transfer characteristics 12-bit resolution mode and s/h gain = 1 (1) symbol parameter conditions min typ max units res resolution differential mode, v vddana = 3v, v adcref0 = 1v, adcfia.seqcfgn.sres = 0, s/h gain = 1 12 bit inl integral non-linearity 2.5 lsb dnl differential non-linearity 1 lsb offset error -5 5 mv gain error -25 0 mv
1266 32117b?avr-03/11 at32uc3c note: 1. the measures are done without any i/o activity on vddana/gndana power domain. 40.8.7 digital to analog converter (dac) characteristics note: 1. dacref corresponds to the internal or external dac reference voltage depending on the dacref settings res resolution differential mode, v vddana = 5v, v adcref0 = 3v, adcfia.seqcfgn.sres = 0, s/h gain = 1 12 bit inl integral non-linearity 3 lsb dnl differential non-linearity 1.2 lsb offset error -30 30 mv gain error -25 0 mv table 40-34. adc and s/h transfer characteristics (continued)12-bit resolution mode and s/h gain = 1 (1) symbol parameter conditions min typ max units table 40-35. channel conversion time and dac clock symbol parameter conditions min typ max units f dac dac clock frequency 1mhz t startup startup time 3s t conv conversion time (latency) no s/h enabled, internal dac 1 s one s/h 1.5 s tw o s / h 2 s throughput rate 1/t conv msps table 40-36. external voltage reference input symbol parameter conditions min typ max units v dacref dacref input voltage range 1.2 v vddana -0.7 v table 40-37. dac outputs symbol parameter conditions min typ max units output range 0.2 v dacref (1) c load output capacitance 0 100 pf r load output resitance 2 k
1267 32117b?avr-03/11 at32uc3c figure 40-4. dac output note: 1. the measures are done without any i/o activity on vddana/gndana power domain. c load r load dac0a uc3c s/h dac table 40-38. transfer characteristics (1) symbol parameter conditions min typ max units res resolution v vddana = 3v, v dacref = 2v, one s/h 12 bit inl integral non-linearity 8 lsb dnl differential non-linearity 6 lsb offset error -30 30 mv gain error -30 30 mv res resolution v vddana = 5v, v dacref = 3v, one s/h 12 bit inl integral non-linearity 12 lsb dnl differential non-linearity 6 lsb offset error -30 30 mv gain error -30 30 mv
1268 32117b?avr-03/11 at32uc3c 40.8.8 analog comparator characteristics note: 1. the measures are done without any i/o activity on vddana/gndana power domain. 40.8.9 usb transceiver characteristics 40.8.9.1 electrical characteristics the usb on-chip buffers comply with the univ ersal serial bus (usb) v2.0 standard. all ac parameters related to these buffers can be foun d within the usb 2.0 electrical specifications. table 40-39. analog comparator characteristics (1) symbol parameter conditions min typ max units positive input voltage range 0 v vddana v negative input voltage range 0 v vddana v v offset offset no hysteresis, low power mode -90 90 mv no hysteresis, high speed mode -25 25 mv v hyst hysteresis low hysteresis, low power mode 100 mv low hysteresis, high speed mode 90 high hysteresis, low power mode 230 mv high hysteresis, high speed mode 150 t delay propagation delay low power mode 10 us high speed mode 0.7 t startup start-up time 20 s table 40-40. vddana scaled reference symbol parameter min typ max units scf acifa.scfi.scf range 0 48 v vddana scaled (64 - scf) * v vddana / 65 v v vddana voltage accuracy 2.5 % table 40-41. electrical parameters symbol parameter conditions min. typ. max. unit r ext recommended external usb series resistor in series with each usb pin with 5% 39
1269 32117b?avr-03/11 at32uc3c 40.9 timing characteristics 40.9.1 startup, reset, and wake-up timing the startup, reset, and wake-up timings are calculated using the following formula: where and are found in table 40-42 . is the delay relative to rcsys, is the period of the cpu cl ock. if another cloc k source than rcsys is selected as cpu clock the startup time of the oscillator, , must be a dded to the wake- up time in the stop, deepstop, and static sleep modes. please refe r to the source for the cpu clock in the ?oscillator characterist ics? on page 1256 for more details about oscillator startup times. tt const n cpu t cpu + = t const n cpu t const t cpu t oscstart table 40-42. maximum reset and wake-up timing parameter measuring max (in s) max startup time from power-up, using regulator vddin_5 rising (10 mv/ms) time from v vddin_5 =0 to the first instruction entering the decode stage of cpu. vddcore is supplied by the internal regulator. 2600 0 startup time from reset release time from releasing a reset source (except por, bod18, and bod33) to the first instruction entering the decode stage of cpu. 1240 0 wake-up idle from wake-up event to the first instruction entering the decode stage of the cpu. 019 frozen 268 209 standby 268 209 stop 268+ 212 deepstop 268+ 212 static 268+ 212 t const n cpu t oscstart t oscstart t oscstart
1270 32117b?avr-03/11 at32uc3c figure 40-5. startup and reset time 40.9.2 reset_n characteristics internal reset decoding stage startup time from reset release reset time vddin_5, vddin_33 vddcore bod18 threshold at power-up voltage time bod33 threshold at power-up table 40-43. reset_n clock waveform parameters symbol parameter condition min. typ. max. units t reset reset_n minimum pulse length 2 * t rcsys clock cycles
1271 32117b?avr-03/11 at32uc3c 40.9.3 usart in spi mode timing 40.9.3.1 master mode figure 40-6. usart in spi master mode with (cpol= cpha= 0) or (cpol= cpha= 1) figure 40-7. usart in spi master mode with (cpol= 0 and cpha= 1) or (cpol= 1 and cpha= 0) note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. 2. where: uspi0 uspi1 miso spck mosi uspi2 uspi3 uspi4 miso spck mosi uspi5 table 40-44. usart in spi mode timing, master mode (1) symbol parameter conditions min max units uspi0 miso setup time before spck rises external capacitor = 40pf 26+ t sample (2) ns uspi1 miso hold time after spck rises 0 ns uspi2 spck rising to mosi delay 11 ns uspi3 miso setup time be fore spck falls 26+ t sample (2) ns uspi4 miso hold time after spck falls 0 ns uspi5 spck falling to mosi delay 11.5 ns t sample t spck t spck 2 t clkusart ------------------------------------ 1 2 -- - ?? ?? t clkusart ? =
1272 32117b?avr-03/11 at32uc3c maximum spi frequency, master output the maximum spi master output frequenc y is given by the following formula: where is the mosi delay, uspi2 or uspi5 depending on cpol and ncpha. is the maximum frequency of the spi pins. please refe r to the i/o pin characteristics section for the maximum frequency of the pins. is the maximum frequency of the clk_spi. refer to the spi chapter for a description of this clock. maximum spi frequency, master input the maximum spi master input frequenc y is given by the following formula: where is the miso setup and hold time, uspi0 + uspi1 or uspi3 + uspi4 depending on cpol and ncpha. is the spi slave response time. please refer to the spi slave datasheet for . is the maximum frequency of the clk_spi. refer to the spi chapter for a description of this clock. 40.9.3.2 slave mode figure 40-8. usart in spi slave mode with (cpol= 0 and cpha= 1) or (cpol= 1 and cpha= 0) f spckmax min f pinmax 1 spin ------------ f clkspi 2 9 ---------------------------- - , (, ) = spin f pinmax f clkspi f spckmax min 1 spin t valid + ----------------------------------- - f clkspi 2 9 ---------------------------- - (,) = spin t valid t valid f clkspi uspi7 uspi8 miso spck mosi uspi6
1273 32117b?avr-03/11 at32uc3c figure 40-9. usart in spi slave mode with (cpol= cpha= 0) or (cpol= cpha= 1) figure 40-10. usart in spi slave mode npcs timing note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. 2. where: uspi10 uspi11 miso spck mosi uspi9 uspi14 uspi12 uspi15 uspi13 nss spck, cpol=0 spck, cpol=1 table 40-45. usart in spi mode timing, slave mode (1) symbol parameter conditions min max units uspi6 spck falling to miso delay external capacitor = 40pf 27 ns uspi7 mosi setup time before spck rises t sample (2) + t clk_usart ns uspi8 mosi hold time after spck rises 0 ns uspi9 spck rising to miso delay 28 ns uspi10 mosi setup time before spck falls t sample (2) + t clk_usart ns uspi11 mosi hold time after spck falls 0 ns uspi12 nss setup time before spck rises 33 ns uspi13 nss hold time after spck falls 0 ns uspi14 nss setup time before spck falls 33 ns uspi15 nss hold time after spck rises 0 ns t sample t spck t spck 2 t clkusart ------------------------------------ 1 2 -- - + ?? ?? t clkusart ? =
1274 32117b?avr-03/11 at32uc3c maximum spi frequency, slave input mode the maximum spi slave input frequency is given by the following formula: where is the mosi setup and hold time, uspi7 + uspi8 or uspi10 + uspi11 depending on cpol and ncpha. is the maximum frequency of the clk_spi. refer to the spi chapter for a description of this clock. maximum spi frequency, slave output mode the maximum spi slave output frequency is given by the following formula: where is the miso delay, uspi6 or uspi9 depending on cpol and ncpha. is the spi master setup time. please refer to the spi masterdatasheet for . is the maximum frequency of the clk_spi. refer to the spi chapter for a description of this clock. is the maximum frequency of the spi pins. please refer to the i/o pin characteris- tics section for the maximum frequency of the pins. 40.9.4 spi timing 40.9.4.1 master mode figure 40-11. spi master mode with (cpol= nc pha= 0) or (cpol= ncpha= 1) f spckmax min f clkspi 2 9 ---------------------------- - 1 spin ------------ (,) = spin f clkspi f spckmax min f clkspi 2 9 ---------------------------- - f pinmax , 1 spin t setup + ------------------------------------ (,) = spin t setup t setup f clkspi f pinmax spi0 spi1 miso spck mosi spi2
1275 32117b?avr-03/11 at32uc3c figure 40-12. spi master mode with (cpol= 0 and ncpha= 1) or (cpol= 1 and ncpha= 0) note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. maximum spi frequency, master output the maximum spi master output frequenc y is given by the following formula: where is the mosi delay, spi2 or spi5 depending on cpol and ncpha. is the maximum frequency of the spi pins. please refer to the i/o pin characteristics section for the maximum frequency of the pins. maximum spi frequency, master input the maximum spi master input frequenc y is given by the following formula: where is the miso setup and hold time, spi0 + spi1 or spi3 + spi4 depending on cpol and ncpha. is the spi slave response time. please refer to the spi slave datasheet for . spi3 spi4 miso spck mosi spi5 table 40-46. spi timing, master mode (1) symbol parameter conditions min max units spi0 miso setup time before spck rises external capacitor = 40pf 28.5+ (t clk_spi )/2 ns spi1 miso hold time after spck rises 0 ns spi2 spck rising to mosi delay 10.5 ns spi3 miso setup time befo re spck falls 28.5 + (t clk_spi )/2 ns spi4 miso hold time after spck falls 0 ns spi5 spck falling to mosi delay 10.5 ns f spckmax min f pinmax 1 spin ------------ (,) = spin f pinmax f spckmax 1 spin t valid + ----------------------------------- - = spin t valid t valid
1276 32117b?avr-03/11 at32uc3c 40.9.4.2 slave mode figure 40-13. spi slave mode with (cpol= 0 and nc pha= 1) or (cpol= 1 and ncpha= 0) figure 40-14. spi slave mode with (cpol= ncp ha= 0) or (cpol= ncpha= 1) figure 40-15. spi slave mode npcs timing spi7 spi8 miso spck mosi spi6 spi10 spi11 miso spck mosi spi9 spi14 spi12 spi15 spi13 npcs spck, cpol=0 spck, cpol=1
1277 32117b?avr-03/11 at32uc3c note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. maximum spi frequency, slave input mode the maximum spi slave input frequency is given by the following formula: where is the mosi setup and hold time, spi7 + spi8 or spi10 + spi11 depending on cpol and ncpha. is the maximum frequency of the clk_spi. refer to the spi chap- ter for a description of this clock. maximum spi frequency, slave output mode the maximum spi slave output frequency is given by the following formula: where is the miso delay, spi6 or spi9 depending on cpol and ncpha. is the spi master setup time. please refer to the spi masterdatasheet for . is the maxi- mum frequency of the spi pins. please refer to the i/o pin characteristics section for the maximum frequency of the pins. 40.9.5 twim/twis timing figure 40-48 shows the twi-bus timing requirements and the compli ance of the device with them. some of these requirements (t r and t f ) are met by the device wi thout requiring user inter- vention. compliance with the other requirements (t hd-sta , t su-sta , t su-sto , t hd-dat , t su-dat-i2c , t low- i2c , t high , and f twck ) requires user intervention through a ppropriate programming of the relevant table 40-47. spi timing, slave mode (1) symbol parameter conditions min max units spi6 spck falling to miso delay external capacitor = 40pf 29 ns spi7 mosi setup time before spck rises 0 ns spi8 mosi hold time after spck rises 6.5 ns spi9 spck rising to miso delay 30 ns spi10 mosi setup time before spck falls 0 ns spi11 mosi hold time after spck falls 5 ns spi12 npcs setup time before spck rises 0 ns spi13 npcs hold time after spck falls 1.5 ns spi14 npcs setup time before spck falls 0 ns spi15 npcs hold time after spck rises 1.5 ns f spckmax min f clkspi 1 spin ------------ (,) = spin f clkspi f spckmax min f pinmax 1 spin t setup + ------------------------------------ (, ) = spin t setup t setup f pinmax
1278 32117b?avr-03/11 at32uc3c twim and twis user interface registers. please refer to the twim and twis sections for more information . notes: 1. standard mode: ; fast mode: . 2. a device must internally provide a hold time of at least 300 ns for twd with reference to the falling edge of twck. notations: c b = total capacitance of one bus line in pf t clkpb = period of twi peripheral bus clock t prescaled = period of twi internal prescaled clock (see chapters on twim and twis) the maximum t hd;dat has only to be met if the device does not stretch the low period (t low-i2c ) of twck. table 40-48. twi-bus timing requirements symbol parameter mode minimum maximum unit requirement device requirement device t r twck and twd rise time standard (1) - 1000 ns fast (1) 20 + 0.1 c b 300 t f twck and twd fall time standard (1) -300 ns fast (1) 20 + 0.1 c b 300 t hd-sta (repeated) start hold time standard (1) 4.0 t clkpb - s fast (1) 0.6 t su-sta (repeated) start set-up time standard (1) 4.7 t clkpb - s fast (1) 0.6 t su-sto stop set-up time standard (1) 4.0 4t clkpb - s fast (1) 0.6 t hd-dat data hold time standard (1) 0.3 (2) 2t clkpb 3.45 ?? s fast (1) 0.9 t su-dat-i2c data set-up time standard (1) 250 2t clkpb -ns fast (1) 100 t su-dat --t clkpb -- t low-i2c twck low period standard (1) 4.7 4t clkpb - s fast (1) 1.3 t low --t clkpb -- t high twck high period standard (1) 4.0 8t clkpb - s fast (1) 0.6 f twck twck frequency standard (1) - 100 khz fast (1) 400 1 12t clkpb ----------------------- - f twck 100 khz f twck 100 khz >
1279 32117b?avr-03/11 at32uc3c 40.9.6 jtag timing figure 40-16. jtag interface signals note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. jtag2 jtag3 jtag1 jtag4 jtag0 tms/tdi tck tdo jtag5 jtag6 jtag7 jtag8 jtag9 jtag10 boundary scan inputs boundary scan outputs table 40-49. jtag timings (1) symbol parameter conditions min max units jtag0 tck low half-period external capacitor = 40pf 21.5 ns jtag1 tck high half-period 8.5 ns jtag2 tck period 29 ns jtag3 tdi, tms setup before tck high 6.5 ns jtag4 tdi, tms hold after tck high 0 ns jtag5 tdo hold time 12.5 ns jtag6 tck low to tdo valid 21.5 ns jtag7 boundary scan inputs setup time 0 ns jtag8 boundary scan inputs hold time 4.5 ns jtag9 boundary scan outputs hold time 11 ns jtag10 tck to boundary scan outputs valid 18 ns
1280 32117b?avr-03/11 at32uc3c 40.9.7 ebi timings see ebi i/o lines description for more details. note: 1. the maximum frequency of the smc interface is the same as the max frequency for the hsb. note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. 2. hold length = total cycle duration - setup duration - pulse durat ion. ?hold length? is for ?ncs rd hold length? or ?nrd hold length?. table 40-50. smc clock signal. symbol parameter max (1) units 1/(t cpsmc ) smc controller clock frequency f cpu mhz table 40-51. smc read signals with hold settings (1) symbol parameter conditions min units nrd controlled (read_mode = 1) smc 1 data setup before nrd high v vdd = 3.0v, drive strength of the pads set to the lowest, external capacitor = 40pf 32.5 ns smc 2 data hold after nrd high 0 smc 3 nrd high to nbs0/a0 change (2) nrd hold length * t cpsmc - 1.5 smc 4 nrd high to nbs1 change (2) nrd hold length * t cpsmc - 0 smc 5 nrd high to nbs2/a1 change (2) nrd hold length * t cpsmc - 0 smc 7 nrd high to a2 - a25 change (2) nrd hold length * t cpsmc - 5.6 smc 8 nrd high to ncs inactive (2) (nrd hold length - n cs rd hold length) * t cpsmc - 1.3 smc 9 nrd pulse width nrd pulse length * t cpsmc - 0.6 nrd controlled (read_mode = 0) smc 10 data setup before ncs high v vdd = 3.0v, drive strength of the pads set to the lowest, external capacitor = 40pf 34.1 ns smc 11 data hold after ncs high 0 smc 12 ncs high to nbs0/a0 change (2) ncs rd hold length * t cpsmc - 3 smc 13 ncs high to nbs0/a0 change (2) ncs rd hold length * t cpsmc - 2 smc 14 ncs high to nbs2/a1 change (2) ncs rd hold length * t cpsmc - 1.1 smc 16 ncs high to a2 - a25 change (2) ncs rd hold length * t cpsmc - 7.2 smc 17 ncs high to nrd inactive (2) (ncs rd hold length - nrd hold length) * t cpsmc - 2.2 smc 18 ncs pulse width ncs rd pulse length * t cpsmc - 3
1281 32117b?avr-03/11 at32uc3c note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. 2. hold length = total cycle duration - setup duration - pulse duration. ?hold length? is for ?ncs wr hold length? or ?nwe hold length? table 40-52. smc read signals with no hold settings (1) symbol parameter conditions min units nrd controlled (read_mode = 1) smc 19 data setup before nrd high v vdd = 3.0v, drive strength of the pads set to the lowest, external capacitor = 40pf 32.5 ns smc 20 data hold after nrd high 0 nrd controlled (read_mode = 0) smc 21 data setup before ncs high v vdd = 3.0v, drive strength of the pads set to the lowest, external capacitor = 40pf 28.5 ns smc 22 data hold after ncs high 0 table 40-53. smc write signals with hold settings (1) symbol parameter conditions min units nrd controlled (read_mode = 1) smc 23 data out valid before nwe high v vdd = 3.0v, drive strength of the pads set to the lowest, external capacitor = 40pf (nwe pulse length - 1) * t cpsmc - 1.4 ns smc 24 data out valid after nwe high (2) nwe pulse length * t cpsmc - 4.7 smc 25 nwe high to nbs0/a0 change (2) nwe pulse length * t cpsmc - 2.7 smc 29 nwe high to nbs2/a1 change (2) nwe pulse length * t cpsmc - 0.7 smc 31 nwe high to a2 - a25 change (2) nwe pulse length * t cpsmc - 6.8 smc 32 nwe high to ncs inactive (2) (nwe hold pulse - ncs wr hold length) * t cpsmc - 2.5 smc 33 nwe pulse width nwe pulse length * t cpsmc - 0.2 nrd controlled (read_mode = 0) smc 34 data out valid before ncs high v vdd = 3.0v, drive strength of the pads set to the lowest, external capacitor = 40pf (ncs wr pulse length - 1) * t cpsmc - 2.2 ns smc 35 data out valid after ncs high (2) ncs wr hold length * t cpsmc - 5.1 smc 36 ncs high to nwe inactive (2) (ncs wr hold length - nwe hold length) * t cpsmc - 2
1282 32117b?avr-03/11 at32uc3c note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. figure 40-17. smc signals for ncs controlled accesses table 40-54. smc write signals with no hold settings (nwe controlled only) (1) symbol parameter conditions min units smc 37 nwe rising to a2-a25 valid v vdd = 3.0v, drive strength of the pads set to the lowest, external capacitor = 40pf 8.7 ns smc 38 nwe rising to nbs0/a0 valid 7.6 smc 40 nwe rising to a1/nbs2 change 8.7 smc 42 nwe rising to ncs rising 8.4 smc 43 data out valid before nwe rising (nwe pulse length - 1) * t cpsmc - 1.2 smc 44 data out valid after nwe rising 8.4 smc 45 nwe pulse width nwe pulse length * t cpsmc - 0 nrd nc s d0 - d15 nwe a2-a25 a0/a1/nb s [3:0] s mc34 s mc35 s mc10 s mc11 s mc16 s mc15 s mc22 s mc21 s mc17 s mc18 s mc14 s mc13 s mc12 s mc18 s mc17 s mc16 s mc15 s mc14 s mc13 s mc12 s mc18 s mc36 s mc16 s mc15 s mc14 s mc13 s mc12
1283 32117b?avr-03/11 at32uc3c figure 40-18. smc signals for nrd and nrw controlled accesses (1) note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. 40.9.8 sdram signals note: 1. the maximum frequency of the sdramc interface is the same as the max frequency for the hsb. nrd ncs d0 - d15 nwe a2-a25 a0/a1/nbs[3:0] smc7 smc19 smc20 smc43 smc37 smc42 smc8 smc1 smc2 smc23 smc24 smc32 smc7 smc8 smc6 smc5 smc4 smc3 smc9 smc41 smc40 smc39 smc38 smc45 smc9 smc6 smc5 smc4 smc3 smc33 smc30 smc29 smc26 smc25 smc31 smc44 table 40-55. sdram clock signal symbol parameter max (1) units 1/(t cpsdck ) sdram controller clock frequency f cpu mhz
1284 32117b?avr-03/11 at32uc3c note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. table 40-56. sdram signal (1) symbol parameter conditions min units sdramc 1 sdcke high before sdck rising edge v vdd = 3.0v, drive strength of the pads set to the highest, external capacitor = 40pf on sdram pins except 8 pf on sdck pins 5.6 ns sdramc 2 sdcke low after sdck rising edge 7.3 sdramc 3 sdcke low before sdck rising edge 6.8 sdramc 4 sdcke high after sdck rising edge 8.3 sdramc 5 sdcs low before sdck rising edge 6.1 sdramc 6 sdcs high after sdck rising edge 8.4 sdramc 7 ras low before sdck rising edge 7 sdramc 8 ras high after sdck rising edge 7.7 sdramc 9 sda10 change before sdck rising edge 6.4 sdramc 10 sda10 change after sdck rising edge 7.1 sdramc 11 address change before sdck rising edge 4.7 sdramc 12 address change after sdck rising edge 4.4 sdramc 13 bank change before sdck rising edge 6.2 sdramc 14 bank change after sdck rising edge 6.9 sdramc 15 cas low before sdck rising edge 6.6 sdramc 16 cas high after sdck rising edge 7.8 sdramc 17 dqm change before sdck rising edge 6 sdramc 18 dqm change after sdck rising edge 6.7 sdramc 19 d0-d15 in setup before sdck rising edge 6.4 sdramc 20 d0-d15 in hold after sdck rising edge 0 sdramc 23 sdwe low before sdck rising edge 7 sdramc 24 sdwe high after sdck rising edge 7.4 sdramc 25 d0-d15 out valid before sdck rising edge 5.2 sdramc 26 d0-d15 out valid after sdck rising edge 5.6
1285 32117b?avr-03/11 at32uc3c figure 40-19. sdramc signals relative to sdck. ras a0 - a9, a11 - a13 d0 - d15 read sdck sda10 d0 - d15 to write sdramc 1 sdcke sdramc 2 sdramc 3 sdramc 4 sdcs sdramc 5 sdramc 6 sdramc 5 sdramc 6 sdramc 5 sdramc 6 sdramc 7 sdramc 8 cas sdramc 15 sdramc 16 sdramc 15 sdramc 16 sdwe sdramc 23 sdramc 24 sdramc 9 sdramc 10 sdramc 9 sdramc 10 sdramc 9 sdramc 10 sdramc 11 sdramc 12 sdramc 11 sdramc 12 sdramc 11 sdramc 12 ba0/ba1 sdramc 13 sdramc 14 sdramc 13 sdramc 14 sdramc 13 sdramc 14 sdramc 17 sdramc 18 sdramc 17 sdramc 18 dqm0 - dqm3 sdramc 19 sdramc 20 sdramc 25 sdramc 26
1286 32117b?avr-03/11 at32uc3c 40.9.9 macb characteristics note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. table 40-57. ethernet mac signals (1) symbol parameter conditions min. max. unit mac 1 setup for mdio from mdc rising v vdd = 3.0v, drive strength of the pads set to the highest, external capacitor = 10pf on macb pins 02.5ns mac 2 hold for mdio from mdc rising 0 0.7 ns mac 3 mdio toggling from mdc falling 0 1.1 ns table 40-58. ethernet mac mii specific signals (1) symbol parameter conditions min. max. unit mac 4 setup for col from tx_clk rising v vdd = 3.0v, drive strength of the pads set to the highest, external capacitor = 10pf on macb pins 0ns mac 5 hold for col from tx_clk rising 0 ns mac 6 setup for crs from tx_clk rising 0.5 ns mac 7 hold for crs from tx_clk rising 0.5 ns mac 8 tx_er toggling from tx_clk rising 16.4 18.6 ns mac 9 tx_en toggling from tx_clk rising 14.5 15.3 ns mac 10 txd toggling from tx_clk rising 13.9 18.2 ns mac 11 setup for rxd from rx_clk 1.3 ns mac 12 hold for rxd from rx_clk 1.8 ns mac 13 setup for rx_er from rx_clk 3.4 ns mac 14 hold for rx_er from rx_clk 0 ns mac 15 setup for rx_dv from rx_clk 0.7 ns mac 16 hold for rx_dv from rx_clk 1.3n ns
1287 32117b?avr-03/11 at32uc3c figure 40-20. ethernet mac mii mode mac 4 mac 2 mac 5 mac 1 mdio mdc col mac 3 tx_clk mac 6 mac 7 crs tx_er mac 8 mac 9 tx_en mac 10 txd[3:0] rx_clk mac 11 mac 12 rxd[3:0] mac 13 mac 14 mac 15 mac 16 rx_er rx_dv
1288 32117b?avr-03/11 at32uc3c note: 1. these values are based on simulation and characterization of other avr microcontrollers manufactured in the same pro- cess technology. these values are not covered by test limits in production. figure 40-21. ethernet mac rmii mode table 40-59. ethernet mac rmii specific signals (1) symbol parameter conditions min. max. unit mac 21 tx_en toggling from tx_clk rising v vdd = 3.0v, drive strength of the pads set to the highest, external capacitor = 10pf on macb pins 11.7 12.5 ns mac 22 txd toggling from tx_clk rising 11.7 12.5 ns mac 23 setup for rxd from tx_clk 4.5 ns mac 24 hold for rxd from tx_clk 0 ns mac 25 setup for rx_er from tx_clk 3.4 ns mac 26 hold for rx_er from tx_clk 0 ns mac 27 setup for rx_dv from tx_clk 4.4 ns mac 28 hold for rx_dv from tx_clk 0 ns tx_clk tx_en mac 22 txd[1:0] rxd[3:0] mac 25 mac 26 mac 27 mac 28 rx_er rx_dv mac 21 mac 23 mac 24
1289 32117b?avr-03/11 at32uc3c 41. mechanical characteristics 41.1 thermal considerations 41.1.1 thermal data table 41-1 summarizes the thermal resistance data depending on the package. 41.1.2 junction temperature the average chip-junction temperature, t j , in c can be obtained from the following: 1. 2. where: ? ja = package thermal resistance, junction-to-ambient (c/w), provided in table 41-1 on page 1289 . ? jc = package thermal resistance, junction-to-ca se thermal resistance (c/w), provided in table 41-1 on page 1289 . ? heat sink = cooling device thermal resistance (c/w), provided in the device datasheet. ?p d = device power consumption (w) estimated from data provided in the section ?power consumption? on page 1250 . ?t a = ambient temperature (c). from the first equation, the user can derive the estimated lifetime of the chip and decide if a cooling device is necessary or not. if a coolin g device is to be fitted on the chip, the second equation should be used to compute the resulting average chip-junction temperature t j in c. table 41-1. thermal resistance data symbol parameter condition package typ unit ja junction-to-ambient thermal resistance no air flow qfn64 20.0 c/w jc junction-to-case thermal resistance qfn64 0.8 ja junction-to-ambient thermal resistance no air flow tqfp64 40.5 c/w jc junction-to-case thermal resistance tqfp64 8.7 ja junction-to-ambient thermal resistance no air flow tqfp100 39.3 c/w jc junction-to-case thermal resistance tqfp100 8.5 ja junction-to-ambient thermal resistance no air flow lqfp144 38.1 c/w jc junction-to-case thermal resistance lqfp144 8.4 t j t a p d ja () + = t j t a p ( d ( heatsink jc )) ++ =
1290 32117b?avr-03/11 at32uc3c 41.2 package drawings figure 41-1. qfn-64 package drawing note: the exposed pad is not connected to anything internally, but should be soldered to ground to increase board level reliabil ity. table 41-2. device and package maximum weight 200 mg table 41-3. package characteristics moisture sensitivity level jdec j-std0-20d - msl 3 table 41-4. package reference jedec drawing reference ms-026 jesd97 classification e3
1291 32117b?avr-03/11 at32uc3c figure 41-2. tqfp-64 package drawing table 41-5. device and package maximum weight 300 mg table 41-6. package characteristics moisture sensitivity level jdec j-std0-20d - msl 3 table 41-7. package reference jedec drawing reference ms-026 jesd97 classification e3
1292 32117b?avr-03/11 at32uc3c figure 41-3. tqfp-100 package drawing table 41-8. device and package maximum weight 500 mg table 41-9. package characteristics moisture sensitivity level jdec j-std0-20d - msl 3 table 41-10. package reference jedec drawing reference ms-026 jesd97 classification e3
1293 32117b?avr-03/11 at32uc3c figure 41-4. lqfp-144 package drawing table 41-11. device and package maximum weight 1300 mg table 41-12. package characteristics moisture sensitivity level jdec j-std0-20d - msl 3 table 41-13. package reference jedec drawing reference ms-026 jesd97 classification e3
1294 32117b?avr-03/11 at32uc3c 41.3 soldering profile table 41-14 gives the recommended soldering profile from j-std-20. note: it is recommended to apply a soldering temperature higher than 250c. a maximum of three reflow passes is allowed per component. table 41-14. soldering profile profile feature green package average ramp-up rate (217c to peak) 3c/sec preheat temperature 175c 25c min. 150 c, max. 200 c temperature maintained above 217c 60-150 sec time within 5 ? c of actual peak temperature 30 sec peak temperature range 260 c ramp-down rate 6 c/sec time 25 ? c to peak temperature max. 8 minutes
1295 32117b?avr-03/11 at32uc3c 42. ordering information table 42-1. ordering information device ordering code carrier type package temperature operating range at32uc3c0512c AT32UC3C0512C-ALUT tray lqfp 144 industrial (-40c to 85c) at32uc3c0512c-alur tape & reel at32uc3c0256c at32uc3c0256c-alut tray at32uc3c0256c-alur tape & reel at32uc3c0128c at32uc3c0128c-alut tray at32uc3c0128c-alur tape & reel at32uc3c064c at32uc3c064c-alut tray at32uc3c064c-alur tape & reel at32uc3c1512c at32uc3c1512c-aut tray tqfp 100 at32uc3c1512c-aur tape & reel at32uc3c1256c at32uc3c1256c-aut tray at32uc3c1256c-aur tape & reel at32uc3c1128c at32uc3c1128c-aut tray at32uc3c1128c-aur tape & reel at32uc3c164c at32uc3c164c-aut tray at32uc3c164c-aur tape & reel at32uc3c2512c at32uc3c2512c-a2ut tray tqfp 64 at32uc3c2512c-a2ur tape & reel at32uc3c2512c-z2ut tray qfn 64 at32uc3c2512c-z2ur tape & reel at32uc3c2256c at32uc3c2256c-a2ut tray tqfp 64 at32uc3c2256c-a2ur tape & reel at32uc3c2256c-z2ut tray qfn 64 at32uc3c2256c-z2ur tape & reel at32uc3c2128c at32uc3c2128c-a2ut tray tqfp 64 at32uc3c2128c-a2ur tape & reel at32uc3c2128c-z2ut tray qfn 64 at32uc3c2128c-z2ur tape & reel at32uc3c264c at32uc3c264c-a2ut tray tqfp 64 at32uc3c264c-a2ur tape & reel at32uc3c264c-z2ut tray qfn 64 at32uc3c264c-z2ur tape & reel
1296 32117b?avr-03/11 at32uc3c 43. errata 43.1 rev e 43.1.1 ast 1 ast wake signal is released one ast clock cycle after the busy register is cleared after writing to the status clear register (scr) the wake signal is released one ast clock cycle after the busy bit in the status register (sr.busy) is cleared. if entering sleep mode directly after the busy bit is cleared the part will wake up immediately. fix/workaround read the wake enable register (wer) and write this value back to the same register. wait for busy to clear before entering sleep mode. 43.1.2 awire 1 awire memory_speed_request comm and does not return correct cv the awire memory_speed_request command does not retu rn a cv co rresponding to the formula in the awire debug interface chapter. fix/workaround issue a dummy read to address 0x100000000 before issuing the memory_speed_request command and use this formula instead: 43.1.3 power manager 1 pllcount value larger than zero can cause pllen glitch initializing the pllcount with a value greater than zero creates a glitch on the pllen sig- nal during asynchronous wake up. fix/workaround the lock-masking mechanism for the pll should not be used. the pllcount field of the pll control register should always be written to zero. 43.1.4 scif 1 pllcount value larger than zero can cause pllen glitch initializing the pllcount with a value greater than zero creates a glitch on the pllen sig- nal during asynchronous wake up. fix/workaround the lock-masking mechanism for the pll should not be used. the pllcount field of the pll control register should always be written to zero. 2 pll lock might not clear after disable under certain circumstances, the lock signal from the phase locked loop (pll) oscillator may not go back to zero after th e pll oscillator has been disabl ed. this can cause the prop- agation of clock signals with the wrong frequency to parts of the system that use the pll clock. fix/workaround pll must be turned o ff before entering stop, deepstop or static sleep modes. if pll has been turned off, a delay of 30us must be observed after the pll has been enabled f sab 7 f aw cv 3 ? ---------------- - =
1297 32117b?avr-03/11 at32uc3c again before the scif.pll0lock bit can be used as a valid indication that the pll is locked. 43.1.5 spi 1 spi data transfer hangs with csr0.csaat==1 and mr.modfdis==0 when csr0.csaat==1 and mode fault detection is enabled (mr.modfdis==0), the spi module will not start a data transfer. fix/workaround disable mode fault detection by writing a one to mr.modfdis. 2 disabling spi has no effect on flag tdre flag disabling spi has no effect on tdre whereas the write data command is filtered when spi is disabled. this means that as soon as the spi is disabled it becomes impossible to reset the tdre flag by writing in the tdr. so if the spi is disabled during a pdca transfer, the pdca will continue to write data in the tdr (as tdre stays hi gh) until its buffer is empty, and all data written after the disable command is lost. fix/workaround disable the pdca, insert 2 nops, disable spi. to continue the transfer: enable spi, enable pdca. 3 spi disable does not work in slave mode spi disable does not work in slave mode. fix/workaround read the last received data, then perform a software reset. 4 spi bad serial clock generation on 2nd chip_select when scbr = 1, cpol=1 and ncpha=0 when multiple cs are in use, if one of the baudrate equals to 1 and one of the others doesn't equal to 1, and cpol=1 and cpha=0, then an aditional pulse will be generated on sck. fix/workaround when multiple cs are in use, if one of the baudrate equals 1, the other must also equal 1 if cpol=1 and cpha=0. 43.1.6 tc 1 channel chaining skips first pulse for upper channel when chaining two channels using the block mode register, the first pulse of the clock between the channels is skipped. fix/workaround configure the lower channel with ra = 0x1 and rc = 0x2 to produce a dummy clock cycle for the upper channel. after the dummy cycle has been generated, indicated by the sr.cpcs bit, reconfigure the ra and rc registers for the lower channel with the real values. 43.1.7 twim 1 smbalert bit may be set after reset the smbus alert (smbalert) bit in the status register (sr) might be erroneously set after system reset. fix/workaround after system reset, clear the sr.smbalert bit before commencing any twi transfer.
1298 32117b?avr-03/11 at32uc3c 43.1.8 twis 1 clearing the nak bit before the btf bit is set locks up the twi bus when the twis is in transmit mode, clearing the nak received (nak) bit of the status reg- ister (sr) before the end of the acknowl edge/not acknowledge cycle will cause the twis to attempt to continue transmitting data, thus locking up the bus. fix/workaround clear sr.nak only after the byte transfer finished (btf) bit of the same register has been set. 43.1.9 usbc 1 upinrqx.inrq field is limited to 8-bits in host mode, when using the upinrqx.inrq feature together with the multi-packet mode to launch a finite number of packet among multi-packet, the multi-packet size (located in the descriptor table) is limited to the upinrq x.inrq value multiply by the pipe size. fix/workaround upinrqx.inrq value shall be less than the number of configured multi-packet.
1299 32117b?avr-03/11 at32uc3c 43.2 rev d 43.2.1 ast 1 ast wake signal is released one ast clock cycle after the busy register is cleared after writing to the status clear register (scr) the wake signal is released one ast clock cycle after the busy bit in the status register (sr.busy) is cleared. if entering sleep mode directly after the busy bit is cleared the part will wake up immediately. fix/workaround read the wake enable register (wer) and write this value back to the same register. wait for busy to clear before entering sleep mode. 43.2.2 awire 1 awire memory_speed_request comm and does not return correct cv the awire memory_speed_request command does not retu rn a cv co rresponding to the formula in the awire debug interface chapter. fix/workaround issue a dummy read to address 0x100000000 before issuing the memory_speed_request command and use this formula instead: 43.2.3 gpio 1 clearing interrupt flags can mask other interrupts when clearing interrupt flags in a gpio port, interrupts on other pins of that port, happening in the same clock cycle will not be registered. fix/workaround read the pvr register of the port before and af ter clearing the interrupt to see if any pin change has happened while clearing the interr upt. if any change occurred in the pvr between the reads, they must be treated as an interrupt. 43.2.4 power manager 1 clock failure detector (cfd) can be issued while turning off the cfd while turning off the cfd, the cfd bit in the status register (sr) can be set. this will change the main cl ock source to rcsys. fix/workaround solution 1: enable cfd in terrupt. if cfd interrupt is issues after turning off the cfd, switch back to original main clock source. solution 2: only turn off the cfd while running the main clock on rcsys. 2 requesting clocks in idle sleep modes will mask all other pb clocks than the requested in idle or frozen sl eep mode, all the pb clocks will be froz en if the twis or the ast need to wake the cpu up. fix/workaround disable the twis or the ast before entering idle or frozen sleep mode. f sab 7 f aw cv 3 ? ---------------- - =
1300 32117b?avr-03/11 at32uc3c 3 pllcount value larger than zero can cause pllen glitch initializing the pllcount with a value greater than zero creates a glitch on the pllen sig- nal during asynchronous wake up. fix/workaround the lock-masking mechanism for the pll should not be used. the pllcount field of the pll control register should always be written to zero. 43.2.5 scif 1 pllcount value larger than zero can cause pllen glitch initializing the pllcount with a value greater than zero creates a glitch on the pllen sig- nal during asynchronous wake up. fix/workaround the lock-masking mechanism for the pll should not be used. the pllcount field of the pll control register should always be written to zero. 2 pll lock might not clear after disable under certain circumstances, the lock signal from the phase locked loop (pll) oscillator may not go back to zero after th e pll oscillator has been disabl ed. this can cause the prop- agation of clock signals with the wrong frequency to parts of the system that use the pll clock. fix/workaround pll must be turned o ff before entering stop, deepstop or static sleep modes. if pll has been turned off, a delay of 30us must be observed after the pll has been enabled again before the scif.pll0lock bit can be used as a valid indication that the pll is locked. 43.2.6 spi 1 spi data transfer hangs with csr0.csaat==1 and mr.modfdis==0 when csr0.csaat==1 and mode fault detection is enabled (mr.modfdis==0), the spi module will not start a data transfer. fix/workaround disable mode fault detection by writing a one to mr.modfdis. 2 disabling spi has no effect on flag tdre flag disabling spi has no effect on tdre whereas the write data command is filtered when spi is disabled. this means that as soon as the spi is disabled it becomes impossible to reset the tdre flag by writing in the tdr. so if the spi is disabled during a pdca transfer, the pdca will continue to write data in the tdr (as tdre stays hi gh) until its buffer is empty, and all data written after the disable command is lost. fix/workaround disable the pdca, insert 2 nops, disable spi. to continue the transfer: enable spi, enable pdca. 3 spi disable does not work in slave mode spi disable does not work in slave mode. fix/workaround read the last received data, then perform a software reset. 4 spi bad serial clock generation on 2nd chip_select when scbr = 1, cpol=1 and ncpha=0 when multiple cs are in use, if one of the baudrate equals to 1 and one of the others doesn't equal to 1, and cpol=1 and cpha=0, then an aditional pulse will be generated on sck.
1301 32117b?avr-03/11 at32uc3c fix/workaround when multiple cs are in use, if one of the baudrate equals 1, the other must also equal 1 if cpol=1 and cpha=0. 43.2.7 tc 1 channel chaining skips first pulse for upper channel when chaining two channels using the block mode register, the first pulse of the clock between the channels is skipped. fix/workaround configure the lower channel with ra = 0x1 and rc = 0x2 to produce a dummy clock cycle for the upper channel. after the dummy cycle has been generated, indicated by the sr.cpcs bit, reconfigure the ra and rc registers for the lower channel with the real values. 43.2.8 twim 1 smbalert bit may be set after reset the smbus alert (smbalert) bit in the status register (sr) might be erroneously set after system reset. fix/workaround after system reset, clear the sr.smbalert bit before commencing any twi transfer. 2 twim twalm polarity is wrong the twalm signal in the twim is active high instead of active low. fix/workaround use an external inverter to invert the signal going into the twim. when using both twim and twis on the same pins, the twalm cannot be used. 43.2.9 twis 1 clearing the nak bit before the btf bit is set locks up the twi bus when the twis is in transmit mode, clearing the nak received (nak) bit of the status reg- ister (sr) before the end of the acknowl edge/not acknowledge cycle will cause the twis to attempt to continue transmitting data, thus locking up the bus. fix/workaround clear sr.nak only after the byte transfer finished (btf) bit of the same register has been set. 2 twis stretch on address match error when the twis stretches twck due to a slave address match, it also holds twd low for the same duration if it is to be receivi ng data. when twis releases twck, it releases twd at the same time. this can cause a twi timing violation. fix/workaround none. 3twalm forced to gnd the twalm pin is forced to gnd when the alternate function is selected and the twis module is enabled. fix/workaround none.
1302 32117b?avr-03/11 at32uc3c 43.2.10 usbc 1 upinrqx.inrq field is limited to 8-bits in host mode, when using the upinrqx.inrq feature together with the multi-packet mode to launch a finite number of packet among multi-packet, the multi-packet size (located in the descriptor table) is limited to the upinrq x.inrq value multiply by the pipe size. fix/workaround upinrqx.inrq value shall be less than the number of configured multi-packet. 43.2.11 wdt 1 clearing the watchdog timer (wdt) counter in second half of timeout period will issue a watchdog reset if the wdt counter is cleared in the second half of the ti meout period, the wdt will immedi- ately issue a watchdog reset. fix/workaround use twice as long timeout period as needed and clear the wdt counter within the first half of the timeout period. if the wdt counter is cl eared after the first half of the timeout period, you will get a watchdog reset immediately. if the wdt counter is not clea red at all, the time before the reset will be tw ice as long as needed.
1303 32117b?avr-03/11 at32uc3c 44. datasheet revision history please note that the referring page numbers in th is section are referred to this document. the referring revision in this section are referring to the document revision. 44.1 rev. b ? 03/11 44.2 rev. a ? 10/10 1 package and pinout: added supply column. updated peripheral functions 2 supply and startup considerations: updated i/o lines power 3 pm: added awen description 4 scif: added vregcr register 5 ast: updated digital tuner formula 6 sdramc: cleaned-up sdcs/ncs names. added version register 7 sau: updated sr.idle 8 usart: updated 9 canif: updated address map figure 10 usbc: updated 11 dacifb: updated 12 programming and debugging: added jtag data registers section 13 electrical characteristics: updated 14 ordering information: updated 15 errata: updated 1 initial revision
1304 32117b?avr-03/11 at32uc3c table of content 1 description ............ .............. .............. ............... .............. .............. ............ 3 2 overview ............ ................ ................ ............... .............. .............. ............ 5 2.1 block diagram ....................................................................................................5 2.2 configuration summary .....................................................................................7 3 package and pinout ................. ................ ................. ................ ............... 9 3.1 package .............................................................................................................9 3.2 peripheral multiplexing on i/o lines .................................................................12 3.3 signals description ..........................................................................................19 3.4 i/o line considerations ...................................................................................25 4 processor and architecture .... ................ ................. ................ ............. 26 4.1 features ..........................................................................................................26 4.2 avr32 architecture .........................................................................................26 4.3 the avr32uc cpu ........................................................................................27 4.4 programming model ........................................................................................32 4.5 exceptions and interrupts ................................................................................37 5 memories ............... .............. .............. ............... .............. .............. .......... 42 5.1 embedded memories ......................................................................................42 5.2 physical memory map .....................................................................................43 5.3 peripheral address map ..................................................................................44 5.4 cpu local bus mapping .................................................................................47 6 supply and startup c onsiderations ............ ................. .............. .......... 49 6.1 supply considerations .....................................................................................49 6.2 startup considerations ....................................................................................52 7 power manager (pm) .. ................ ................. ................ ................. .......... 53 7.1 features ..........................................................................................................53 7.2 overview ..........................................................................................................53 7.3 block diagram .................................................................................................54 7.4 i/o lines description .......................................................................................54 7.5 product dependencies ....................................................................................54 7.6 functional description .....................................................................................55 7.7 user interface ..................................................................................................61 7.8 module configuration ......................................................................................83
1305 32117b?avr-03/11 at32uc3c 8 system control interface (scif) ............. ................. ................ ............. 84 8.1 features ..........................................................................................................84 8.2 description .......................................................................................................84 8.3 i/o lines description .......................................................................................84 8.4 product dependencies ....................................................................................84 8.5 functional description .....................................................................................85 8.6 user interface ..................................................................................................93 8.7 module configuration ....................................................................................135 9 asynchronous timer (ast) ...... ................. ................ .............. ........... 136 9.1 features ........................................................................................................136 9.2 overview ........................................................................................................136 9.3 block diagram ...............................................................................................137 9.4 product dependencies ..................................................................................137 9.5 functional description ...................................................................................138 9.6 user interface ................................................................................................143 9.7 module configuration .....................................................................................163 10 watchdog timer (wdt) ......... ................ ................. ................ ............. 164 10.1 features ........................................................................................................164 10.2 overview ........................................................................................................164 10.3 block diagram ...............................................................................................164 10.4 product dependencies ..................................................................................164 10.5 functional description ...................................................................................165 10.6 user interface ................................................................................................170 10.7 module configuration ....................................................................................176 11 interrupt controller (intc) ............. .............. .............. .............. ........... 177 11.1 features ........................................................................................................177 11.2 overview ........................................................................................................177 11.3 block diagram ...............................................................................................177 11.4 product dependencies ..................................................................................178 11.5 functional description ...................................................................................178 11.6 user interface ................................................................................................181 11.7 interrupt request signal map ........................................................................185 12 external interrupt controller (eic) ..... .............. .............. ............ ........ 190 12.1 features ........................................................................................................190 12.2 overview ........................................................................................................190
1306 32117b?avr-03/11 at32uc3c 12.3 block diagram ...............................................................................................190 12.4 i/o lines description .....................................................................................191 12.5 product dependencies ..................................................................................191 12.6 functional description ...................................................................................191 12.7 user interface ................................................................................................195 12.8 module configuration ....................................................................................211 13 frequency meter (freqm) ...... ................ ................. ................ ........... 212 13.1 features ........................................................................................................212 13.2 overview ........................................................................................................212 13.3 block diagram ...............................................................................................212 13.4 product dependencies ..................................................................................212 13.5 functional description ...................................................................................213 13.6 user interface ................................................................................................215 13.7 module configuration ....................................................................................226 14 peripheral event controller (pevc) ............ .............. .............. ........... 228 14.1 features ........................................................................................................228 14.2 overview ........................................................................................................228 14.3 block diagram ...............................................................................................229 14.4 i/o lines description .....................................................................................230 14.5 product dependencies ..................................................................................230 14.6 functional description ...................................................................................231 14.7 user interface ................................................................................................233 14.8 module configuration ....................................................................................254 15 flash controller (flashc) ... ................ ................. ................ ............. 256 15.1 features ........................................................................................................256 15.2 overview ........................................................................................................256 15.3 product dependencies ..................................................................................256 15.4 functional description ....................................................................................257 15.5 flash commands ..........................................................................................262 15.6 general-purpose fuse bits .............................................................................264 15.7 security bit .....................................................................................................267 15.8 user interface ................................................................................................268 15.9 fuses settings ...............................................................................................298 15.10 calibration settings .......................................................................................301 15.11 serial number ................................................................................................307
1307 32117b?avr-03/11 at32uc3c 15.12 module configuration ....................................................................................307 16 hsb bus matrix (hmatrixb) ................ ................. ................ ............. 308 16.1 features ........................................................................................................308 16.2 overview ........................................................................................................308 16.3 product dependencies ..................................................................................308 16.4 functional description ...................................................................................308 16.5 user interface ................................................................................................312 16.6 bus matrix connections .................................................................................320 17 external bus interface (ebi ) ................ .............. .............. ............ ........ 322 17.1 features ........................................................................................................322 17.2 overview ........................................................................................................322 17.3 block diagram ...............................................................................................323 17.4 i/o lines description .....................................................................................323 17.5 product dependencies ..................................................................................324 17.6 functional description ...................................................................................326 17.7 application example ......................................................................................326 18 static memory controller (smc) ......... .............. .............. ............ ........ 329 18.1 features ........................................................................................................329 18.2 overview ........................................................................................................329 18.3 block diagram ...............................................................................................330 18.4 i/o lines description .....................................................................................330 18.5 product dependencies ..................................................................................330 18.6 functional description ...................................................................................331 18.7 user interface ................................................................................................363 19 sdram controller (sdramc) ................ ................. ................ ........... 370 19.1 features ........................................................................................................370 19.2 overview ........................................................................................................370 19.3 block diagram ...............................................................................................371 19.4 i/o lines description .....................................................................................371 19.5 application example ......................................................................................372 19.6 product dependencies ..................................................................................373 19.7 functional description ...................................................................................374 19.8 user interface ................................................................................................383 20 peripheral dma controller (pdca) ............. .............. .............. ........... 398
1308 32117b?avr-03/11 at32uc3c 20.1 features ........................................................................................................398 20.2 overview ........................................................................................................398 20.3 block diagram ...............................................................................................399 20.4 product dependencies ..................................................................................399 20.5 functional description ...................................................................................400 20.6 performance monitors ...................................................................................402 20.7 user interface ................................................................................................404 20.8 module configuration ....................................................................................432 21 memory dma controller (m dma) ......... ................. ................ ............. 434 21.1 features ........................................................................................................434 21.2 overview ........................................................................................................434 21.3 product dependencies ..................................................................................434 21.4 functional description ...................................................................................435 21.5 single transfer mode ....................................................................................436 21.6 descriptor mode ............................................................................................437 21.7 user interface ................................................................................................439 21.8 module configuration ....................................................................................456 22 secure access unit (sau) .... ................ ................. ................ ............. 457 22.1 features ........................................................................................................457 22.2 overview ........................................................................................................457 22.3 block diagram ...............................................................................................457 22.4 product dependencies ..................................................................................458 22.5 functional description ...................................................................................459 22.6 user interface ................................................................................................463 22.7 module configuration .....................................................................................478 23 general-purpose input/output controller (gpio) .... .............. ........... 479 23.1 features ........................................................................................................479 23.2 overview ........................................................................................................479 23.3 block diagram ...............................................................................................479 23.4 i/o lines description .....................................................................................480 23.5 product dependencies ..................................................................................480 23.6 functional description ...................................................................................481 23.7 user interface ................................................................................................486 23.8 module configuration ....................................................................................511 24 ethernet mac (macb) ........ .............. ............... .............. .............. ........ 513
1309 32117b?avr-03/11 at32uc3c 24.1 features ........................................................................................................513 24.2 overview ........................................................................................................513 24.3 block diagram ...............................................................................................514 24.4 product dependencies ..................................................................................514 24.5 functional description ...................................................................................515 24.6 programming interface ..................................................................................527 24.7 user interface ................................................................................................530 24.8 module configuration ....................................................................................586 25 universal synchro nous asynchronous receiver tr ansmitter (usart) 588 25.1 features ........................................................................................................588 25.2 overview ........................................................................................................588 25.3 block diagram ...............................................................................................590 25.4 i/o lines description ....................................................................................591 25.5 product dependencies ..................................................................................592 25.6 functional description ...................................................................................593 25.7 user interface ................................................................................................651 25.8 module configuration ....................................................................................682 26 serial peripheral interface (spi) ................ ................ .............. ........... 684 26.1 features ........................................................................................................684 26.2 overview ........................................................................................................684 26.3 block diagram ...............................................................................................685 26.4 application block diagram .............................................................................685 26.5 i/o lines description .....................................................................................686 26.6 product dependencies ..................................................................................686 26.7 functional description ...................................................................................686 26.8 user interface ................................................................................................697 26.9 module configuration ....................................................................................724 27 two-wire master interface (twim) .............. .............. .............. ........... 726 27.1 features ........................................................................................................726 27.2 overview ........................................................................................................726 27.3 list of abbreviations ......................................................................................727 27.4 block diagram ...............................................................................................728 27.5 application block diagram2 ...........................................................................728 27.6 i/o lines description .....................................................................................728
1310 32117b?avr-03/11 at32uc3c 27.7 product dependencies ..................................................................................729 27.8 functional description ...................................................................................730 27.9 user interface ................................................................................................743 27.10 module configuration ....................................................................................760 28 two-wire slave interface (twi s) ................. .............. .............. ........... 761 28.1 features ........................................................................................................761 28.2 overview ........................................................................................................761 28.3 list of abbreviations ......................................................................................762 28.4 block diagram ...............................................................................................762 28.5 application block diagram .............................................................................763 28.6 i/o lines description .....................................................................................763 28.7 product dependencies ..................................................................................763 28.8 functional description ...................................................................................764 28.9 user interface ................................................................................................775 28.10 module configuration ....................................................................................791 29 can interface (canif) ...... .............. .............. .............. .............. ........... 792 29.1 features ........................................................................................................792 29.2 overview ........................................................................................................792 29.3 block diagram ...............................................................................................793 29.4 i/o lines description .....................................................................................793 29.5 product dependencies ..................................................................................793 29.6 functional description ...................................................................................794 29.7 user interface ................................................................................................804 29.8 module configuration ....................................................................................832 30 inter-ic sound controller (i isc) ............ ................. ................ ............. 833 30.1 features ........................................................................................................833 30.2 overview ........................................................................................................833 30.3 block diagram ...............................................................................................834 30.4 i/o lines description .....................................................................................834 30.5 product dependencies ..................................................................................834 30.6 functional description ...................................................................................835 30.7 iisc application examples ............................................................................841 30.8 user interface ................................................................................................844 30.9 module configuration .....................................................................................859 31 timer/counter (tc) ........... .............. .............. .............. .............. ........... 860
1311 32117b?avr-03/11 at32uc3c 31.1 features ........................................................................................................860 31.2 overview ........................................................................................................860 31.3 block diagram ...............................................................................................861 31.4 i/o lines description .....................................................................................861 31.5 product dependencies ..................................................................................861 31.6 functional description ...................................................................................862 31.7 user interface ................................................................................................877 31.8 module configuration ....................................................................................900 32 usb interface (usbc) ....... .............. .............. .............. .............. ........... 901 32.1 features ........................................................................................................901 32.2 overview ........................................................................................................901 32.3 block diagram ...............................................................................................901 32.4 i/o lines description .....................................................................................903 32.5 product dependencies ..................................................................................904 32.6 functional description ...................................................................................905 32.7 user interface ................................................................................................934 32.8 module configuration ....................................................................................993 33 pulse width modulation c ontroller (pwm) . .............. .............. ........... 994 33.1 features ........................................................................................................994 33.2 overview ........................................................................................................994 33.3 block diagram ...............................................................................................996 33.4 i/o lines description .....................................................................................998 33.5 product dependencies ..................................................................................999 33.6 functional description .................................................................................1000 33.7 user interface ..............................................................................................1028 33.8 module configuration ..................................................................................1084 34 quadrature decoder (qdec) ................ ................. ................ ........... 1085 34.1 features ......................................................................................................1085 34.2 overview ......................................................................................................1085 34.3 block diagram .............................................................................................1086 34.4 i/o lines description ...................................................................................1086 34.5 product dependencies ................................................................................1086 34.6 functional description .................................................................................1087 34.7 user interface ..............................................................................................1094 34.8 module configuration ..................................................................................1111
1312 32117b?avr-03/11 at32uc3c 35 analog comparator interface (acifa) .. ................ ................ ........... 1112 35.1 features ......................................................................................................1112 35.2 overview ......................................................................................................1112 35.3 block diagram .............................................................................................1113 35.4 product dependencies ................................................................................1114 35.5 functional description .................................................................................1114 35.6 user interface ..............................................................................................1118 35.7 module configuration ...................................................................................1137 36 adc interface (adcifa) .... ............. .............. .............. .............. ......... 1140 36.1 features ......................................................................................................1140 36.2 overview ......................................................................................................1141 36.3 block diagram .............................................................................................1142 36.4 i/o lines description ...................................................................................1143 36.5 product dependencies ................................................................................1143 36.6 functional description .................................................................................1144 36.7 user interface ..............................................................................................1157 36.8 module configuration ...................................................................................1184 37 dacifb interface (dacifb) ................ ................ ................. ............. 1186 37.1 features ......................................................................................................1186 37.2 overview ......................................................................................................1186 37.3 block diagram .............................................................................................1187 37.4 i/o lines description ...................................................................................1188 37.5 product dependencies ................................................................................1188 37.6 functional description .................................................................................1189 37.7 user interface ..............................................................................................1193 37.8 module configuration ..................................................................................1214 38 awire uart (aw) ............ .............. .............. .............. .............. ........... 1215 38.1 features ......................................................................................................1215 38.2 overview ......................................................................................................1215 38.3 block diagram .............................................................................................1215 38.4 i/o lines description ...................................................................................1216 38.5 product dependencies ................................................................................1216 38.6 functional description .................................................................................1216 38.7 user interface ..............................................................................................1219 38.8 module configuration ..................................................................................1232
1313 32117b?avr-03/11 at32uc3c 39 programming and debugging .. ................. .............. .............. ........... 1233 39.1 overview ......................................................................................................1233 39.2 service access bus .....................................................................................1233 39.3 on-chip debug ............................................................................................1236 39.4 jtag and boundary-scan (jtag) ...............................................................1244 39.5 jtag instruction summary .........................................................................1252 39.6 awire debug interface (aw) .......................................................................1269 39.7 module configuration ..................................................................................1286 40 electrical characteristics ... ................. ................ ................. ............. 1287 40.1 absolute maximum ratings* .......................................................................1287 40.2 supply characteristics .................................................................................1287 40.3 maximum clock frequencies ......................................................................1288 40.4 power consumption ....................................................................................1288 40.5 i/o pin characteristics .................................................................................1293 40.6 oscillator characteristics .............................................................................1295 40.7 flash characteristics ...................................................................................1299 40.8 analog characteristics .................................................................................1300 40.9 temperature sensor characteristics ...........................................................1309 40.10 timing characteristics .................................................................................1310 41 mechanical characteristics ..... ................ ................. .............. ........... 1328 41.1 thermal considerations ..............................................................................1328 41.2 package drawings .......................................................................................1329 41.3 soldering profile ..........................................................................................1333 42 ordering information .......... ................. ................ ................. ............. 1334 43 errata ........... ................ ................ ................. .............. .............. ........... 1336 43.1 rev e ............................................................................................................1336 43.2 rev d ............................................................................................................1338 44 datasheet revision history ................ ................ ................. ............. 1342 44.1 rev. b ? 02/11 .............................................................................................1342 44.2 rev. a ? 10/10 .............................................................................................1342
32117b-avr?03/11 ? 2011 atmel corporation. all rights reserved. atmel ? , atmel logo and combinations thereof, avr ? and others are registered trademarks or trademarks of atmel corporation or its subsidiaries. other terms and product names may be trademarks of others. headquarters international atmel corporation 2325 orchard parkway san jose, ca 95131 usa tel: 1(408) 441-0311 fax: 1(408) 487-2600 atmel asia unit 1-5 & 16, 19/f bea tower, millennium city 5 418 kwun tong road kwun tong, kowloon hong kong tel: (852) 2245-6100 fax: (852) 2722-1369 atmel europe le krebs 8, rue jean-pierre timbaud bp 309 78054 saint-quentin-en- yvelines cedex france tel: (33) 1-30-60-70-00 fax: (33) 1-30-60-71-11 atmel japan 9f, tonetsu shinkawa bldg. 1-24-8 shinkawa chuo-ku, tokyo 104-0033 japan tel: (81) 3-3523-3551 fax: (81) 3-3523-7581 product contact web site www.atmel.com technical support avr32@atmel.com sales contact www.atmel.com/contacts literature requests www.atmel.com/literature 97505 disclaimer: the information in this document is provided in connection with atmel products. no license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of atmel products. except as set forth in atmel?s terms and condi- tions of sale located on atmel?s web site, atmel assumes no li ability whatsoever and disclaims any express, implied or statutor y warranty relating to its products including, but not limited to, the implied warranty of merchantability, fitness for a particu lar purpose, or non-infringement. in no event shall atmel be liable for any direct, indirect, consequential, punitive, special or i nciden- tal damages (including, without limitation, damages for loss of profits, business interruption, or loss of information) arising out of the use or inability to use this document, even if atme l has been advised of the possibility of such damages. atmel makes no representations or warranties with respect to the accuracy or comp leteness of the contents of this document and reserves the rig ht to make changes to specifications and product descriptions at any time without notice. atmel does not make any commitment to update the information contained her ein. unless specifically provided otherwise, atmel products are not suitable for, and shall not be used in, automotive applications. atmel?s products are not int ended, authorized, or warranted for use as components in applications in tended to support or sustain life.


▲Up To Search▲   

 
Price & Availability of AT32UC3C0512C-ALUT

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X